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.

AppGameKit Classic Chat / automatic rounding on integer casting? wtf!

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Jan 2016 09:15
Just wasted 2 hours tracking this down. Sometimes I got proper grid coordinates, sometimes not. I'm used to every other language on the planet simply dropping the decimal when I assign a float to an integer, DB included. Why in the heck does AppGameKit round it?



"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Jan 2016 10:22
I'd never noticed that before, but you are right!
I'm sure it didn't work that way previously. But I just checked V1.08 and the behaviour is the same. I will have to add floor() to my calculations.
Anyone know if DBP behaves the same way?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Jan 2016 11:31 Edited at: 5th Jan 2016 11:35
yo. thats uncommon.
result is 0 and 1

otherwise often there was add a 0.5 for a nearest conversion and here we not need it.

AGK (Steam) V2.0.16 : Windows 10 Pro 64 Bit : AMD (15.30.1025) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 5th Jan 2016 15:09
I remember the old discussion we had on this topic. IIRC that's standard for BASIC. AppGameKit have always done that.

You should use:
integer Trunc( a )
"Returns the integer part of a float value with no rounding either way. "


If you want:
integer Floor( a )
"Rounds a float to the next lowest integer. This differs from Trunc when using negative numbers, Trunc( -1.6 ) is -1 but Floor( -1.6 ) is -2. "

Login to post a reply

Server time is: 2024-11-25 13:49:42
Your offset time is: 2024-11-25 13:49:42