Test for a decimal (Figured out)

Non-platform specific questions.

Test for a decimal (Figured out)

Postby tlah » Wed Sep 30, 2009 10:45 pm

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)
User avatar
tlah
 
Posts: 66
Joined: Sun Apr 06, 2008 12:10 pm
Location: In your head, readin' ur mind
Score: 2 Give a positive score

Re: Test for a decimal (Figured out)

Postby Fuzzy » Thu Oct 01, 2009 1:11 am

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.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron