Forum Topic: Composite, Odd, Fractions

(68 views • 3 replies)

This topic is 1 page long.

<< < > >>
Questioning

Kwing

Reply To Post Reply & Quote

Posted at: 11/9/09 04:49 PM

Kwing DARK LEVEL 24

Sign-Up: 07/24/07

Posts: 2,017

How do I ask Flash to check if a variable is composite or odd? How do I ask it to check if it's a whole number or a fraction/decimal?

I'm making a racing game, and it's going to have two checkpoints, each of which add 0.5 to the Lap. It's going to look something like this:

onClipEvent(enterFrame){
if(this.hitTest(_parent.player)||_parent.laps=_whole){
laps+=0.5;
}}

Except that I don't know how to check for whole or decimal/fractions.


Sad

Archon68

Reply To Post Reply & Quote

Posted at: 11/9/09 05:09 PM

Archon68 LIGHT LEVEL 22

Sign-Up: 09/09/07

Posts: 3,482

I think you're over complicating things; what exactly do you want to do?

I code in AS2, in case I forgot to mention it.

BBS Signature

None

milchreis

Reply To Post Reply & Quote

Posted at: 11/9/09 05:59 PM

milchreis DARK LEVEL 16

Sign-Up: 01/11/08

Posts: 451

when a number is odd, its last bit must be 1.

"Even if it's just cynicism that remained to push us ahead, we'll carry on!"


Happy

zuperxtreme

Reply To Post Reply & Quote

Posted at: 11/9/09 06:10 PM

zuperxtreme NEUTRAL LEVEL 08

Sign-Up: 01/02/05

Posts: 1,629

You can use Modulus:

myVar % 2 ? trace("myVar is even") : trace("myVar is odd");

Same thing for decimal numbers:

myVar %1 ? trace("Not decimal") : trace("Is decimal");

BTW, "? : " is a fancy way of doing if(){}else{} ; :p


All times are Eastern Standard Time (GMT -5) | Current Time: 11:01 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!