Is there a function like this?

Megax60

Member
for example, if a number is 1,2,3,4, etc... its true, but if it has decimal its false, is there something like that? it would save me a lot'a time

(sry if my english is bad)
 

FrostyCat

Member
That is a good point, I suppose. Personally, I would rather have distinct data types and avoid coding that depends on floats having a close enough value. But gms/gml is what it is and I can live with it.
There's a distinct 64-bit integer type now. If the original poster decides to code in a numerically unstable way that precludes the use of fixed-point integers (e.g. storing a potentially fractional amount of dollars instead of a non-fractional amount of cents), that's his fault, not GM's.
 

jo-thijs

Member
I hope you're careful with your code and math so you're not tripped up by rounding errors due to limited precision in floating point representation.
Less concerning that it sounds in GameMaker due to built-in epsilon.
No, chamaeleon does have a good point.
What if the factional part is 0.99999999999999?

Just execute this:
Code:
var a = 1 - math_get_epsilon() * 0.5;
show_message(frac(a));
It shows 1.00, which would not work with th originally proposed solution.
This is a safer alternative:
Code:
if (frac(number) == 0 || abs(frac(number)) == 1)
There's a distinct 64-bit integer type now. If the original poster decides to code in a numerically unstable way that precludes the use of fixed-point integers (e.g. storing a potentially fractional amount of dollars instead of a non-fractional amount of cents), that's his fault, not GM's.
I don't believe that's relevant?
There's nothing that indicates that Megax60 decides to program in a numerically unstable way, nor that they can more appropriately use int64 for their purposes.
The answer YAL provided gives unexpected results in some case as noticed by chameleon.
Issues that would arise from that would not necessarily be Megax60's fault.
 
Top