Why floating point result?

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
User avatar
wrathchild
Dragon
Posts: 546
Joined: Thu May 24, 2007 9:44 am
Location: Copenhagen, Denmark
Contact:

Why floating point result?

Post by wrathchild »

Hi all

I have this formula for a token property field:

Code: Select all

SwingMod:{if(ST<9, ceil(ST/2)-6, ((ST/4)-floor((ST-1)/4))*4-2)}
Why does this formula return a result with a floating point number? ST is simply

Code: Select all

ST:10
or another integer.

This similar formula does not return a floating point:

Code: Select all

ThrustMod:{floor(if(ST<11,ceil(ST/2)-7,(ceil((ST-10)/2)/4-floor(ceil((ST-10)/2-1)/4))*4-2))}
I''d rather avoid the floating point.
Entering the Digital Age of Roleplaying.
Part of the Resident GURPS Lobby.
Calling for Halos to be Hexified.

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Why floating point result?

Post by aliasmask »

ST / 4.. you'll want to ceil or round that?

User avatar
wrathchild
Dragon
Posts: 546
Joined: Thu May 24, 2007 9:44 am
Location: Copenhagen, Denmark
Contact:

Re: Why floating point result?

Post by wrathchild »

THANK YOU! Was driving me nuts! (the solution was to be floor'ing that whole "else" statement - just the ST/4 wouldn't work on its own)
Entering the Digital Age of Roleplaying.
Part of the Resident GURPS Lobby.
Calling for Halos to be Hexified.

Post Reply

Return to “MapTool”