I want to round numbers to hundreds using javascript:
10651.89 = 10700 10649.89 = 10600 60355.03 = 60400 951479.29 = 951500 1331360.95 = 1331400
How can i do this?
Many thanks.
function roundHundred(value){ return Math.round(value/100)*100 }
Live example with your test cases: http://jsfiddle.net/LaPGs/
you can divide it by 100 first, then use Math.round and finally multiply it by 100.
Math.round
> Math.round(10651.89 / 100) * 100 10700
function(x) { return Math.round(x / 100) * 100; }
we can use Math.ceil for this.
var rawNumber = 10651.89; roundFigure= Math.ceil(rawNumber /100)*100
Source: https://habr.com/ru/post/1393709/More articles:Size / Compression MJPEG vs MPEG-4 - streamSecure Textfield meaning in UIAutomation script - iphoneTweet button does not appear - htmlExcel Tier Search Queries - excelSearch Database (multiple criteria) - excelExcel search with multiple queries - excelIs it possible that data conversion will convert binary data to Windows-1252 encoding? - stringjavascript eventlisteners removal - javascriptAccess device device music files from iPhone app programmatically - iosRedirect cout from C ++ dll to text field in C # - c ++All Articles