Jump to content
Sign in to follow this  
Chaos

Calculation problem

Recommended Posts

Hello, i have a little problem. I need round number, but my hint says "0" for the variable "_n".

_posMax = 8;
_cnt = 14;

_n = _posMax/_cnt;
;~1.5
_n = floor (_n/1);

hint format ["_n - %1",_n];

Where is the problem?

Share this post


Link to post
Share on other sites

Floor will always round down. Ceil will always round up. Round will round to nearest.

Maybe good to know is what programmers in other languages will often do is Floor ( n + 0.5 ) This will round to nearest but using a round down command.

Just noticed that you joined the forum 1 day after me :)

Edited by wamingo

Share this post


Link to post
Share on other sites

_posMax = 8;

_cnt = 14;

_n = 8/14;

_n = floor (0.57142..../1);

_n = 0

Your calculation is correct. It will be always 0 (zero).

Use ceil or round

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×