Many times we need to display a numeric output as multiple of some value.
Being a simple calculation we overlook and make it NaN error bug when
multiple-of is 0
Additionally from experience I want to ask,
if second parameter is 0, not a number or missing then it should be
considered as 1.
Because that is what in practice we end up doing in that case.
ie, should act like
Math.floor(10, 3.5) ==> 7
Math.floor(10) ==> 10
Math.floor(10, 0) ==> 10
Math.floor(10, null) ==> 10
Math.floor(10, undefined) ==> 10
Math.floor(10, NaN) ==> 10
Math.floor(10, "") ==> 10
Thanks
Biju
Many times we need to display a numeric output as multiple of some value.
Being a simple calculation we overlook and make it NaN error bug when
multiple-of is 0
Can we have an additional parameter for Math.floor(), Math.ceil(), Math.round()
like the one in EXCEL FLOOR function
see http://spreadsheets.about.com/od/excelfunctions/qt/90208_floor.htm
(Excel gives result 0, if second parameter is 0)
Additionally from experience I want to ask,
if second parameter is 0, not a number or missing then it should be
considered as 1.
Because that is what in practice we end up doing in that case.
ie, should act like
Math.floor(10, 3.5) ==> 7
Math.floor(10) ==> 10
Math.floor(10, 0) ==> 10
Math.floor(10, null) ==> 10
Math.floor(10, undefined) ==> 10
Math.floor(10, NaN) ==> 10
Math.floor(10, "") ==> 10
Thanks
Biju
Many times we need to display a numeric output as multiple of some value. Being a simple calculation we overlook and make it NaN error bug when multiple-of is 0
Can we have an additional parameter for Math.floor(), Math.ceil(), Math.round() like the one in EXCEL FLOOR function see spreadsheets.about.com/od/excelfunctions/qt/90208_floor.htm (Excel gives result 0, if second parameter is 0)
Additionally from experience I want to ask, if second parameter is 0, not a number or missing then it should be considered as 1. Because that is what in practice we end up doing in that case.
ie, should act like Math.floor(10, 3.5) ==> 7
Math.floor(10) ==> 10
Math.floor(10, 0) ==> 10
Math.floor(10, null) ==> 10
Math.floor(10, undefined) ==> 10
Math.floor(10, NaN) ==> 10
Math.floor(10, "") ==> 10
Thanks Biju