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 / Whole real number not showing decimal point

Author
Message
Battoad
AGK Developer
18
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 11th Jan 2014 11:04
I want to increment a real number by 0.1 and for the full real number to print to screen, however whole numbers miss the decimal point off, e.g 0.0 displays as 0, 1.0 displays as 1 but decimals in between such as 0.1 correctly display as 0.1
How do I get the whole numbers to include .0 at the end.


MonoCoder
19
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 11th Jan 2014 12:21 Edited at: 11th Jan 2014 12:23
You can use str$() with an extra argument for number of digits after the decimal place to show.



0 will show as 0.0, 1 as 1.0, and so on for all integers, while 0.1, 0.2 etc. will remain as expected.
Battoad
AGK Developer
18
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 11th Jan 2014 12:43
Magic MonoCoder.
I didn't know of the extra argument so thank you for updating me and for your code solution.
All the best.

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Jan 2014 17:37
I should read more carefully. I glossed over Mono's answer, not realizing that STR already does this function I just wrote



Login to post a reply

Server time is: 2025-05-16 02:26:51
Your offset time is: 2025-05-16 02:26:51