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 / Rounding down and up.

Author
Message
Zero G Scott
18
Years of Service
User Offline
Joined: 14th Dec 2007
Location: California, USA, Earth, Sol Sys
Posted: 16th Jan 2013 05:19
Looking for a way to round a float to an integer, down and up. All the examples I keep finding involve converting to strings and manipulating the strings. Am I missing something? There's no command for rounding? Just making sure before I dig into string concatenation. Thanks!
Zero G Scott
18
Years of Service
User Offline
Joined: 14th Dec 2007
Location: California, USA, Earth, Sol Sys
Posted: 16th Jan 2013 05:52
Found it, apparently I forgot to search for roundING

round = int(decimal# + .5)
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 16th Jan 2013 11:05
there are floor and ceil commands

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 16th Jan 2013 14:39 Edited at: 16th Jan 2013 14:40
Quote: "round = int(decimal# + .5)"

This will not work for negative numbers. Here's what you want: n = int(n#+n#) - int(n#)

Shh... you're pretty.

Login to post a reply

Server time is: 2026-07-07 18:44:53
Your offset time is: 2026-07-07 18:44:53