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 Discussion / DB won't do decimals!

Author
Message
Vice
22
Years of Service
User Offline
Joined: 15th Apr 2003
Location:
Posted: 1st May 2003 23:11
HI! whenever i try + get a decimal eg 2.4, db always rounds the # to an integer eg 2. Y? ive had db a while now, and i dont remember it ever doin this b4.
is it sumthin ive changed, like sum settin thts buggered it up, or is there a command to change this?
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 1st May 2003 23:20
When you're naming the variable, and you know it will be using real numbers, put a # behind the name. i.e number#

This code for example should return a real value:

value#=2.5+0.6
print value#

Whatever I did I didn't do it!
Dr DooMer
22
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 1st May 2003 23:25 Edited at: 1st May 2003 23:25
Try this:

input# = 2.4
output# = input# + 4.0
print output#

This should give a vlue of 6.4; the only thing I can think of that you're doing wrong is not putting a '.0' after integers used for floating-point calculations.

If this doesn't help, try posting your source-code, so we can have a look and point out any mistakes you might have made.

"I am a living, thinking entity who was created in the sea of information."
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd May 2003 00:56
Yes, as Dr. Mooer says, put at least one floating point value in your calc. If you don't have one, multiply it by 1.0...

x = (y / z) * 1.0

Thanks in advance.
All the Best,
StevieVee
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 2nd May 2003 06:59
Danmatsuma
22
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 2nd May 2003 07:36
*lol* yes they will

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia

Login to post a reply

Server time is: 2025-05-17 06:53:48
Your offset time is: 2025-05-17 06:53:48