Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / What's up with the really odd math?

Author
Message
Anomaly452
14
Years of Service
User Offline
Joined: 14th Aug 2011
Location: Cyberspace
Posted: 23rd Aug 2011 18:33
If you run this script in DBP the number ends up getting all jumbled into something like: '1.32212e-012'. Why does this happen? Is there any way to prevent this? Maybe setup the variable so there can only be one decimal number?



The wisest leader is the one that can avoid the conflict in the first place.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 23rd Aug 2011 20:07
You can use Int to miss out the decimal places if you want...

Return Integer=INT(Value)

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Aug 2011 21:13
Quote: "Why does this happen?"

It happens automatically to reduce the number of characters being displayed. Your number '1.32212e-012' is effectively the same as '0.00000000000132212'.

Quote: "Is there any way to prevent this?"

Use the STR$ function and specify the number of decimal places you want to use.

Login to post a reply

Server time is: 2026-07-10 08:27:59
Your offset time is: 2026-07-10 08:27:59