Hans,

thank you for the very clear answer. I have a feeling now why things went wrong and will work with your suggested psuedo code.
Thank you again.

Jiri

Hans Wichman wrote:
Hi Jiri,

well not really, since 100 / 0.15 is not a whole number, it is 666,66666
etc.
Although this is a great number home to many a great song, 100.05 is
divisible by 0.15 hence the result.

If you really want to do what you want you should deduct the
Math.floorfirst, perform the step calculations on the remainder and
add the deducted
Math.floor, eg in pseudo:

100,2 is split into 100 and 0.2
100 + Math.round (0.2/0.15)*0.15
trace(100 + Math.round (0.2/0.15)*0.15);

Im not sure you wont get rounding errors though...

greetz
JC


On Jan 8, 2008 12:08 PM, Jiri Heitlager <[EMAIL PROTECTED]>
wrote:

Hmm, i understand the logic now, but there is this small thing I dont
understand

Math.round(100.2/0.15)*0.15)

results in 100.2 it should actually be 100.15...

Is it possible to get this result, can somebody please help me out (again)

Jiri

Hans Wichman wrote:
Hi,
sonething like:
trace (Math.round(100.1/0.15)*0.15);
trace (Math.round(100.35/0.5)*0.5);
trace (Math.round(100.175/0.125)*0.125);
greetz
JC

On Jan 8, 2008 10:05 AM, Jiri Heitlager <[EMAIL PROTECTED]>
wrote:

 Hello,

i am not at all a mathematic/calculus wonder and would therefore like
some help with the following.
I need to round numbers up or down to a certain step size. As an
example:
nVal = 100,1
nStep = 0,15
outcome = 225,15

nVal = 100,35
nStep = 0,5
outcome = 100,5

nVal = 100,175
nStep = 0,125
outcome = 100,125

I just havent got a clue on how to approach this problem. Can somebody
shed some light on a possible way to go?

Thank you,

Jiri


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to