fixes formatting and parsing of numbers #396

wants to merge 4 commits into


None yet

2 participants

  • negative numbers were not detected
  • String.format is non existent
  • considers culture settings on Number parsing (here in germany 9,41 should not be parsed to 9)
  • exponential formatting was missing culture awareness
@nikhilk nikhilk commented on the diff Sep 16, 2013
@@ -47,6 +47,12 @@ function parseNumber(s) {
if (!s || !s.length) {
return 0;
+ if (
nikhilk Sep 16, 2013 Owner

The parse functions aren't yet setup for globalization (unlike the format functions). The intent here was to only parse per the invariant/neutral culture.

andekande Sep 16, 2013 Contributor

Yeah, I was thinking to introduce a parseNumber(culture, s) but as you said, would be inconsistent to parseDate where culture awarenes is much more challenging. Nevertheless when coming from .Net one expects parsing to be culture aware, which in case of Numbers is easy to achieve. So I thought I would implement a robust way in the framework, rather to writing my own convert logic.

andekande Nov 4, 2013 Contributor

Hum, I overcame a situation where forcibly parsing with currentCulture is not desireable:
jQuery.Select("#ID").GetCSS("font-size") => may return "22.5pt"
With my addition parseNumber("22.5pt") gets 225.
So I'll better keep my own version of culture aware parsing in my utils.

Jan Hesse added some commits May 9, 2014
Jan Hesse fixes unreliable rounding in various browsers
short version of:

eg: rounding of 1.0005 with precision of 3 is different in IE than in

string res = string.Format(CultureInfo.CurrentCulture, "{0:3}", 1.0005);
Jan Hesse semicolon missing 8ab2717
Jan Hesse format -0 as 0 ecfdd2b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment