-
Finding remainders and assigning variables
This is a flash AS3 related question.
Firstly let me start by saying these forums are great what a wealth of knowledge.
It is time for me to stop looking and start asking I'm afraid.
Please help an old fella out with a taxing question.
I wish to take a number
Example 2.1
And end up with two variables
1st variable containing the whole number and the second with the remainder.
Example
var one = 2
var two = 0.1
I have tried the following
var testnumber = 2.1
var rounded = Math.floor(testnumber);
trace("Rounded number");
trace(rounded );
var answer = testnumber - rounded
trace ("answer");
trace (answer);
but the remainder number comes out with 0.10000000000000009
Is there any way I can make this number become 0.1?
To make matters more complicated I also wish to work with negative numbers.
var testnumber = -1.4
i.e
var one = -1
var two = 0.4
the var testnumber could be anywhere between -10.0 and 50.0
Would this work the same as above if a solution could be found?
Any ideas?
Regards
Adey
Last edited by adey_flash; 06-28-2011 at 05:10 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|