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 / Why does this return 0?

Author
Message
Game Master1330
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 5th Apr 2012 19:28 Edited at: 5th Apr 2012 19:29
Hi,
I am having a bit of trouble with a fromula at the moment.
The calculation i am trying to do is below, but it keeps returning 0.
Can anyone find the problem?



Matt

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Apr 2012 19:45


That will evaluate to zero because both arguments are integers so DBPro will use integer division and ignore the remainder which is 0.99 in this case. If you want full float precision then make sure that each component part of the calculation has at least one float. For example



will evaluate to 0.0, whereas



will evaluate to 1 (give or take the 6th significant figure or so).
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 5th Apr 2012 22:37
STAB#=1.5


/ 50) + 2) * STAB * Effecti

see ur problem?

more 3d models .x/.obj and more foramts here:
[href]https://www.turbosquid.com/Search/Index.cfm?keyword=gogetax1&x=0&y=0[href]
Game Master1330
18
Years of Service
User Offline
Joined: 19th Oct 2007
Location: (GetReaderXYZ() * 42 ) / 0
Posted: 5th Apr 2012 22:57
thanks guys its sorted now

Position Object Game Master1330, Object Position X(Reader), Object Position Y(Reader), Object Position Z(Reader) - 5

Hide Object Game Master1330
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Apr 2012 23:38
@Sergey K

Well spotted. I didn't notice that was wrong as well.

Login to post a reply

Server time is: 2026-07-09 20:54:54
Your offset time is: 2026-07-09 20:54:54