I believe this behavior of the floor function 5 decimal 60 seconds binary options system that works intended. Note that it says “the next lowest integer”.
As in, -1 is logically greater than -1. To go lower the floor function would go to -2 which is logically less than -1. Floor isn’t trying to give you the number closest to zero, it’s giving you the lowest bounding integer of a float. A correction to the funcion floor_dec from the user “php is the best”. 59 because the zero at left position is deleted. I just added a ‘1’ and after the floor or ceil call remove with a substr.
Warning: do not use Seppili’s function to floor with decimals. It will lead you to a lot of trouble because of float number precision. Very useful with trigonometric functions to reduce the angle argument to a circle that includes angle 0. 1 if the function can return 0, to avoid floating point errors with logarithms! PHP is constantly evolving within a large range of values. Floats have a mind of their own, and what may look like an integer stored in a float isn’t. The thing to remember here is that the way a float stores a value makes it very easy for these kind of things to happen.
99 was multiplied by 100, the actual value stored in the float was probably something like 7998. 9999999999999999999999999999999999, PHP would print out 7999 when the value is displayed but floor would therefore round this down to 7998. THe moral of this story – never use float for anything that needs to be accurate! For calculating the number of days, hours, minutes and seconds to an event. 05 to the value if the value must have 1 decimal accuracy, or 0. 005 for 2 decimals accuracy, or 0. Yet bringing the same number – the cubic root of 64 retrieved in the very same manner – to the floor will result in a value of 3 only.
This behaviour is in no way exceptional. It is pivotal to check whether you are dealing with genuine integers or floats in disguise. For instance, if you have a length of 5. Now, although there is a specific function in PHP for rounding, rounding can also be performed with the floor function.