Jump to content

Simple yet complicated mathematics


Recommended Posts

$temp is currently 6. But the variable result can be changing every time to a different number so it is not a fixed value.

 

Anyway, for this $temp * 1.1666666, the result will be 6.99999996. Since I used the floor function, it will be rounded down to 6.

 

Is there any way when the value is more then>*.49999 it will stay at *.5 instead of *?

 

Example: 6.51111111, 6.78948123, 6.9747124

 

Expected Output: 6.5

 

Example: 6.49999999, 6.12412431, 6.33452361

 

Expected Output: 6

 

Do note that, $temp value will be ever changing..thank you!

 

Link to comment
Share on other sites

yea initially i was doing nearest half rather than floored half, edited post...

 

fringe test:

6.9999999 * 2 = 13.999998

13.99998 floored = 13

13/2 = 6.5

 

6*2 = 12

12 floored = 12

12/2 = 6

 

6.4999 * 2 = 12.99998

floored = 12

12/2 = 6

 

6.5 * 2 = 13

floored = 13

13/2 = 6.5

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.