Author Topic: problem with str with integers  (Read 1054 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
problem with str with integers
« on: May 07, 2019, 12:34:41 PM »

 It is not a big problem, but this:

Code: [Select]
print str(5)
outputs this:

Code: [Select]
4.9999999999999912
 You have to do this:

Code: [Select]
print str(5, 0)
to get this:

Code: [Select]
5

Aurel

  • Guest
Re: problem with str with integers
« Reply #1 on: May 07, 2019, 01:32:34 PM »
heh
i don't know which version u use
but i get proper result with

print (5)  ' res 5

it is not with integers than with numbers

what you get if you type
 int a =5
print str(a) ?

Brian Alvarez

  • Guest
Re: problem with str with integers
« Reply #2 on: May 07, 2019, 03:35:55 PM »
Probably one too old to even be talking.  ;D

 Sorry i forgot i havent upgraded. :)

Brian Alvarez

  • Guest
Re: problem with str with integers
« Reply #3 on: May 07, 2019, 05:06:25 PM »
can somebody try this in the newest version?

Code: [Select]
    numberformat(0,1,0,0,0,0)
    print str(10, 0)   
    numberformat

In my version every number is formatted correctly, but for some reason, numbers bigger than 9 are scientifically notated, for example 10 is formatted as: 1E+01

JRS

  • Guest
Re: problem with str with integers
« Reply #4 on: May 07, 2019, 07:07:19 PM »
I see that notation when ScroptBasic integers auto convert to doubles for extended precision.

Charles Pegge

  • Guest
Re: problem with str with integers
« Reply #5 on: May 08, 2019, 06:51:46 AM »
Hi Brian,

In my current version This does not go into scientic notation 1.0E+1
Code: [Select]
numberformat(0,1,0,0,0,0)
    print str(10, 0)   
    numberformat

but I noticed that numberformat does not work in JIT mode because the setting is in the host's variable space.