gracelang / language

Design of the Grace language and its libraries
GNU General Public License v2.0
6 stars 1 forks source link

Number Semantics #181

Closed smarr closed 1 year ago

smarr commented 5 years ago

This may or may not be a simple question.

My understanding from the last discussions I had on this topic is that the spec(*) leaves some room for how numbers are represented and what number types are actually supported.

Since I am cleaning up the Moth repository, and wanted to get the underlying SOMns tests running, I thought, I'd ask what the desired results for a few computations are:

print((4/3) + (4/5)) // → 2.133333

print(  1/  1)    // → 1
print(  3/  2)    // → 1.5
print(  4/ -2)    // → -2
print( -6/  3)    // → -2
print(-12/ -4)    // → 3
print(  7/ 2.0)   // → 3.5
print(  7/ 3.5)   // → 2

The annotated results are what I get on: http://web.cecs.pdx.edu/~grace/ide/

Could you confirm that those are the desired results?

Would also be great to know whether these values are supposed to have specific types.

Thanks!

*) I didn't check whether there were any changes to the spec.

KimBruce commented 5 years ago

Those all seem correct to me. The types of all the answers are Number. Is there any other option for the types?

On Jul 12, 2019, at 12:53 PM, Stefan Marr notifications@github.com wrote:

This may or may not be a simple question.

My understanding from the last discussions I had on this topic is that the spec(*) leaves some room for how numbers are represented and what number types are actually supported.

Since I am cleaning up the Moth repository, and wanted to get the underlying SOMns tests running, I thought, I'd ask what the desired results for a few computations are:

print((4/3) + (4/5)) // → 2.133333

print( 1/ 1) // → 1 print( 3/ 2) // → 1.5 print( 4/ -2) // → -2 print( -6/ 3) // → -2 print(-12/ -4) // → 3 print( 7/ 2.0) // → 3.5 print( 7/ 3.5) // → 2 The annotated results are what I get on: http://web.cecs.pdx.edu/~grace/ide/ http://web.cecs.pdx.edu/~grace/ide/ Could you confirm that those are the desired results?

Would also be great to know whether these values are supposed to have specific types.

Thanks!

*) I didn't check whether there were any changes to the spec.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gracelang/language/issues/181?email_source=notifications&email_token=AAN2D6RJPNHYERO5FDEN6IDP7DOLVA5CNFSM4ICQH5V2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G66UROA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAN2D6XFREFNNP7AEI5A66DP7DOLVANCNFSM4ICQH5VQ.

smarr commented 5 years ago

The spec is still a fuzzy around that:

In Grace, numbers are objects. Grace supports a single type Number, which accommodates at least 64-bit precision floats. Implementations may support other classes of numbers, and may define types that extend Number; a full specification of numeric types is yet to be completed.

I thought, I just ask, in case opinions developed since the last time I looked at this a year or more ago.