Ranter
Join devRant
Do all the things like
++ or  rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power realtime personalized recommendations and activity feeds using a simple API
Learn More
Comments

C0D463806168dWell, it's not wrong ðŸ˜‚
It's not what you would expect first look, but it's actually right. 
theabbie5852168dweren't you expecting 10?
That's how math works, Greatest Integer lower than or equal to 9.4 
theabbie5852168d@blindXfish In which mathematics does floor of 9.4 gives 0?
It doesn't give infinity in JS, which language are you using? 
blindXfish965168d@theabbie I didn't said floor of  9.4, I said floor in general concept of the meaning. In my reality, at least until now, floor (in general concept) had a meaning of getting closer to 0 instead of getting closer to minus infinity.

theabbie5852168d@blindXfish If you go by the definition "Greatest Integer lower than or equal to something" It will make sense.

C0D463806168d@theabbie any C based language would give 10
@blindXfish you may want to look at a number line.
Floor() rounds to next "lowest" whole number.
When your in negative digits, you have to continue going down "10" not up, which would be CEIL(), to 0 
theabbie5852168d@blindXfish Depends on the usecase, Rules don't break for negative integers, Maybe you're looking to round off it.

fuckyouall3254168d@theabbie Do you...
 round toward zero?
 round away from zero?
 round toward negative infinity?
 round toward positive infinity?
;) 
theabbie5852168d@junon Round off is independent of sign, If fractional part is less than 0.5, Remove the Fractional part, if greater than 0.5, Increment the absolute value and preserve the sign,
round(9.4) = 9
round(9.6) = 10 
fuckyouall3254168d@theabbie It depends; libraries like MPFR give you a choice because the behavior of rounding can be specified differently in different scenarios.

blindXfish965168d@theabbie so much rage and frustration in floor(). I typed basically one word. :D

fuckyouall3254168d@theabbie Again, which definition? There is the mathematical definition, but that does not always apply in the CS realm.
"Floor" can mean "truncation", which works very differently than your definition (e.g. it rounds toward zero). 
fuckyouall3254168d@theabbie Yes, but the application of `floor()` in computer science obviously has conflicting definitions.
Not all symbols and functions are equal across mathematics/scientific disciplines. This is also why mathematic symbols change their meanings depending on the domain. 
theabbie5852168d@junon If you are using floor to parse integers, that's a bad practice, having different applications doesn't mean mathematical rules changed, floor Function is still doing the mathematical floor.

Oktokolo3061168d@junon
Do you know any programming language, wich implements floor different from mathematics? 
fuckyouall3254168d@Oktokolo Do you know what MPFR is?
Also did anyone actually read my comment? I never even said floor to begin with. Just that floor is sometimes implemented as truncate. 
bioDan5675168d@theabbie I think you mean mathematical axioms. Mathematical rules can be disputed, extended or limitted to different domains.

theabbie5852167d@bioDan I meant mathematical definitions, Floor is defined as "Greatest integer lower than or equal to" this is a completely unambiguous definition, this definition doesn't change anywhere, in whatever Programming language this function is implemented.

Oktokolo3061167d@junon
MPFR implements mpfr_floor like defined by mathematics (returns nearest integer less than or equal to given value).
So do you actually know of any example for "the application of `floor()` in computer science obviously has conflicting definitions"? 
theabbie5852167d@junon That is a way of storing it, It's because of memory limitations, even if it wraps up that does not mean huge_number + 1 is equal to the wrapped up negative number. If computers had unlimited memory, these problems wouldn't exist.

bioDan5675167d@theabbie oh i dont dispute that definition of floor at all, just commenting on the use of the term "mathematical rules". Definition seems more correct. Ship it! ðŸ˜ƒ

ThermalCube226167dJavaScript to the rescue! (lol)
~~(9.4) returns 9
~~(9.4) returns 9
It's a hack but it works
Floor(9.4)
rant