Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Numeric Interpretation of Strings

49 views
Skip to first unread message

Sidney Reilley

unread,
Oct 30, 2021, 2:49:32 PM10/30/21
to
Using Okane mumps!

don't understand how

+"123.45e4"

becomes 1.2345e+06

The scientific notation needs to be quoted! a numeric operator needs
to be present. Okay so far, but I don't grok how we go from 123.45e4
to 1.2345e+06.

ed de moel

unread,
Oct 30, 2021, 9:52:11 PM10/30/21
to
I would expect +"123.45e4" to return 1234500
The unary + operator should return a canonic number.
(even if it happens to be numerically the same as 1.2345E6...)

Ed

ed de moel

unread,
Oct 30, 2021, 9:54:47 PM10/30/21
to
Or, actually, it should return 123.45, because (in the standard) lowercase "e" is not recognized as "exponential notation".
But many implementations treat "E" and "e" the same in this context.

Ed

4dmonster

unread,
Oct 31, 2021, 2:02:40 PM10/31/21
to
I suppose this happens because 1.2345e+06 is normalized representation of 123.45e4 and floating numbers are stored in that way. When you force type conversation it understands you have floating number. If you want canonical integer you should do explicit convert to integer.

воскресенье, 31 октября 2021 г. в 04:54:47 UTC+3, ed de moel:

Sidney Reilley

unread,
Oct 31, 2021, 4:21:08 PM10/31/21
to
It appears that I need a refresher mini-tut about scientific
notation! Thx for all the input.
0 new messages