4

how is this posible 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 culture is nl-BE

jsfiddle: http://jsfiddle.net/Ed6VY/

hakre
  • 193,403
  • 52
  • 435
  • 836

1 Answers1

5

toFixed results in a string. Strings are compared character-by-character. "9" comes after "1", so "99.2" is greater than "100.0".

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592