javascript - Round number to nearest thousand, up or down depending on the number -
i want round number nearest thousand, @ moment i'm using this:
math.ceil(value/1000)*1000;
but goes up, if type 1001 go 2000, want go or down depeding on number, example 1001 goes 1000 or 1400 goes 1000 1500 goes 2000
edit:
if(value<1000){ value = 1000; }else{ value = math.round(value/1000)*1000; }
this want:
math.round(value/1000)*1000
examples:
math.round(1001/1000)*1000 1000 math.round(1004/1000)*1000 1000 math.round(1500/1000)*1000 2000
Comments
Post a Comment