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.

Author
Message
Oliver
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Switzerland
Posted: 3rd Nov 2004 03:55
Well even my calculator can do this ...is there any way of rounding numbers? The int() command doesn't round up or down, it simply cuts of the decimals. I know the funny decimals in DB have already been discussed before but I did a search for rounding up/down numbers and found nothing. I really need to have exact numbers when saving from my level editor.

Thanks
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 3rd Nov 2004 10:59
This is Mentor's code (slightly adapted):



There is something inherently weird about rounding using computers, though, that sometimes causes innacuracies. I tried putting this code into a function and it caused all kinds of errors.


Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 3rd Nov 2004 11:25
It is probably because most decimal numbers can't actually be represented in binary (float) form. 24.35768 is actually 24.3576793671 and some others are worse off.

Oliver
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Switzerland
Posted: 4th Nov 2004 01:41
Brilliant Thanks Ric

Login to post a reply

Server time is: 2024-09-23 04:21:25
Your offset time is: 2024-09-23 04:21:25