Menu

#57 about numbers [r891]

Unstable_(example)
open
None
5
2017-09-01
2017-09-01
No

Hi Jim,

Those are the changes:


FIX: log(0)

If you run this line:

print log(0)

the result will be:

-inf

Solved
I also split the error message ERROR_LOGRANGE into:
ERROR_LOGRANGE "Unable to calculate the logarithm of a number less than or equal to 0"
ERROR_SQRRANGE "Unable to calculate the root of a negative number"


FIX: ASIN() and ACOS()

Run this

print acos(10)
print asin(-9)

You will get:

nan.0
nan.0

Solved
Add also ERROR_ASINACOSRANGE "Unable to calculate the arc-sine or arc-cosine of a value outside the interval [-1.0, +1.0]"


FIX: Number too large

Run this:

print  99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

result:

inf

or this:

print tan(99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)

result:

nan

Solved
Add error message at compiling time COMPERR_NUMBERTOOLARGE: "Number too large"


FIX: Put correct value on stack when fail to convert string to number

Run this using WARN to bad type conversion:

print  cos ("999999999999e500") 

The result is:

WARNING on line 1: Unable to convert string to number, zero used.
nan.0

Solved


CHANGE: Min. value for "Number of digits to print numbers"

An integer can be printed using 10 digits:

print 2147483647

So, there is no reason to have the minumum value of Settings panel -> "Number of digits to print numbers": 8
In this case an integer will be printed by using 10 digits and the same number as floating point will look a lot different:

print 2147483647
print 214748364.0

result:

2147483647
2.147484e+9

Solved
Change min value of "Number of digits to print numbers" from preferences panel to 10 (the number of digits of an integer)


FIX: Perfect floating point numbers

This is a continuation of the discussion: https://sourceforge.net/p/kidbasic/patches/36/

Set "Number of digits to print numbers" to 10.
Set "Always show decimal point on floating point numbers" to true

Run this:

print 0.12345678912345
print 9.12345678912345
print 9999999999
print 0.0
print 1234567891.0

It will print:

0.123456789
9.12345679       # 9 digits
9999999999.0     # 11 digits
0                # where is floating point?
1e+9             # what?

Solved
The (new) correct output is:

0.123456789
9.123456789
9.999999999e+9
0.0
1.234567891e+9

Respectfully,
Florin Oprea

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.