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.

Newcomers DBPro Corner / 'Double Float' Printing ?....

Author
Message
DigitalDreams
13
Years of Service
User Offline
Joined: 3rd Aug 2011
Location:
Posted: 17th Aug 2011 22:44
Hi Friends

I'm trying to use the double float (15 digit) precision yet cannot even print out such a number correctly....see this attempt (which generates no errors)

pi AS DOUBLE FLOAT
pi=22/7
ans$=str$(pi)
print ans$

Gives "3" !?. Printing 'pi' directly gives the same...

I know, it's been 7 years or so since last playing with DB.

Thanks in advance....
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 18th Aug 2011 03:16
It's because you need .0 at the end of the numbers to make it calculate as a float otherwise it'll treat it as a whole number.

I changed the PI variable in your code to P because PI() is a command in IanMs Matrix 1 Utilities Plugin.



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Aug 2011 16:11
You can also control the number of decimal places:

ans$=str$(p,3)

DigitalDreams
13
Years of Service
User Offline
Joined: 3rd Aug 2011
Location:
Posted: 18th Aug 2011 17:41
Thanks guys !

Login to post a reply

Server time is: 2024-11-24 03:09:07
Your offset time is: 2024-11-24 03:09:07