Page 1 of 1

Test for a decimal (Figured out)

PostPosted: Wed Sep 30, 2009 10:45 pm
by tlah
ok, I'm using Game Editor to create a calculator that converts our standard numbers into Mayan numerals (for a science/computer fair). I have the basic layout done, but I need a function that can tell if a number is a decimal number (Real numbers). Thanks in advance.
If you don't understand waht I mean by my problem, or how I am going to set this up, some example code would be
Code: Select all
if((numbers.textNumber / 20) = //then the code to find the decimal)
{
 // other text
}

Edited: Never mind, i figured it out. :mrgreen: I didn't need to use decimals, I was using the wrong rounding code (was using ceil instead of floor)

Re: Test for a decimal (Figured out)

PostPosted: Thu Oct 01, 2009 1:11 am
by Fuzzy
Code: Select all
if ( (floor(num)-num) != 0)
{
    // its not a decimal
}


You really should not do math with textNumber. Do your math on another variable and then assign that to textNumber.