javascript - JS - Format number with 2 decimal not rounded -


i format number 2 decimal places without rounding. excluded tofixed() function.

i have tried way

a = 1,809999 b = 27,94989  = math.floor(a * 100) / 100; --> 1,8 b = math.floor(b * 100) / 100; --> 27,94  or  = number(a.tostring().match(/^\d+(?:\.\d{0,2})?/)); --> 1,8 b = number(b.tostring().match(/^\d+(?:\.\d{0,2})?/)); --> 27,94 

unfortunately, second decimal of zero, , deleted, how keep , have = 1.80? thank you

(math.floor(a * 100) / 100).tofixed(2); 

with tofixed(2) !

jsfiddle demo


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -