a = 1.4
b = 1.6
c = 0
Forums
number vs. real poll
16 posts
• Page 2 of 2 • 1, 2
Re: number vs. real poll
If you can set "number" to be "int16" then what happens for this code?
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: number vs. real poll
simplistically same as if you'd done
or probably more correctly
If you setup literals or defaults that dont make sense for the numeric type mapping you still get errors....
- Code: Select all
a as int16 = 1.4
b as int16 = 1.6
c as int16 = 0
or probably more correctly
- Code: Select all
a = 1.4 to int16
b = 1.6 to int16
c = 0 to int16
If you setup literals or defaults that dont make sense for the numeric type mapping you still get errors....
- hopscc
- Posts: 632
- Location: New Plymouth, Taranaki, New Zealand
Re: number vs. real poll
"a = 1.6" should not give "1".
-number shall remain an option for fractional values like float and decimal.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: number vs. real poll
I think what hopscc meant initially is that if the user sets number to int, then functions like "def f(x as number) as number" will take and return an int. This might make sense for applications like number theory in which ints are used all the time, and in which we might be interested in using number for everything and later on decide if we want number to be int, int64, BigInt or whatever.
However, I agree with Chuck that hopscc is wrong in suggesting that code such as "a = 1.6" should lead to "a" taking the type "int". Type inference should be more important in such case. No matter what "number" translates too, "a = 1.6" should always lead to "a" being of a fractional type. Otherwise things would be weird and confusing.
However, I agree with Chuck that hopscc is wrong in suggesting that code such as "a = 1.6" should lead to "a" taking the type "int". Type inference should be more important in such case. No matter what "number" translates too, "a = 1.6" should always lead to "a" being of a fractional type. Otherwise things would be weird and confusing.
- jonathandavid
- Posts: 159
Re: number vs. real poll
jonathandavid wrote:I think what hopscc meant initially is that if the user sets number to int, then functions like "def f(x as number) as number" will take and return an int. This might make sense for applications like number theory in which ints are used all the time, and in which we might be interested in using number for everything and later on decide if we want number to be int, int64, BigInt or whatever.
But for that, I would make "int" configurable as in: cobra -int:int64 ...
Although that seems very low priority compared to other items.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: number vs. real poll
Chuck wrote:Although that seems very low priority compared to other items.
Agreed.
- jonathandavid
- Posts: 159
16 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 51 guests