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 / Rounding numbers

Author
Message
mr joe
20
Years of Service
User Offline
Joined: 12th Aug 2004
Location: Edinburger, Scotland. DBC
Posted: 11th Oct 2004 06:30
This is probably an easy question but this kind of basic stuff dosen't seem to be covered anywhere in my dark basic manual or in the program.

Is there a function to round numbers? If not what is the best way to do it?

Thanks,

Joe
PoHa!84
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 11th Oct 2004 13:26
hmmm... that depends on the kind of number you're using, and what you want to round to.

if you want to round decimals to whole numbers, you could use the int() command.

if you want to round whole numbers, it gets a little bit more difficult, but not much.

Why do you want to round numbers anyways?

something
NathanF
21
Years of Service
User Offline
Joined: 24th Mar 2004
Location:
Posted: 11th Oct 2004 13:55
This is what I use:

Hope it helps

-Formerly DarkSephiroth-
mr joe
20
Years of Service
User Offline
Joined: 12th Aug 2004
Location: Edinburger, Scotland. DBC
Posted: 12th Oct 2004 06:11
NathF: Thanks, thats perfect. Don't know why I didn't think of it.

PoHa: Thanks, my problem was that the INT command only returns the integer so 7.8 would be 7 when it should be 8. I'm making a Bomberman style game using tiles and I wanted to round the numbers so I could know what tile my character is on.
fik
20
Years of Service
User Offline
Joined: 28th Sep 2004
Location:
Posted: 12th Oct 2004 08:26
Or you could use this to speed up code if you use it a lot
PoHa!84
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: To your left.
Posted: 12th Oct 2004 08:30
Ah... now i understand... hehe... didn't think about the int always rounding down, sorry about that. BTW, I loved Bomberman! let me know when you finish it!

something
fik
20
Years of Service
User Offline
Joined: 28th Sep 2004
Location:
Posted: 12th Oct 2004 08:36
Thats it and i wouldn't leave it in a fuction either dont know what i was thinking! your reply beat my edit

Login to post a reply

Server time is: 2025-05-25 21:37:03
Your offset time is: 2025-05-25 21:37:03