how is it possible that 100> = 99.2 is false?
var ls = parseFloat(("100").replace(",", ".")).toFixed(1); var val = parseFloat(("99,2").replace(",", ".")).toFixed(1); alert(ls >= val); /*=> result is false ...but it should be true */
ui - nl-BE
jsfiddle: http://jsfiddle.net/Ed6VY/
toFixed results in a string. Lines are compared by character. "9" appears after "1" , so "99.2" greater than "100.0" .
toFixed
"9"
"1"
"99.2"
"100.0"
Source: https://habr.com/ru/post/1432090/More articles:Replacing a sql column value based on a column of another table - mappingCannot send or receive presence with ASmack - javaoperator overload: normal MSVS, but crashes in g ++ - c ++How to change subtitle font color on TCheckBox, TRadioButton, TGroupBox? - propertiesFiltering meaningless phrases - nlpInsert text before a specific line using Bash - bash"Validation agent could not connect to the test controller" VS2012 Agents - tfsHow can I properly control the scene orientation on Android using an AIR mobile phone? - androidDoes Google api change file ownership? - javaStrange behavior java.util.Set.contains (Object o) - javaAll Articles