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
https://forums.phpfreaks.com/topic/261988-simple-yet-complicated-mathematics/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.