Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting value from decimal (with dot) string #710

Open
SooR opened this issue Apr 2, 2021 · 1 comment · May be fixed by #754
Open

Getting value from decimal (with dot) string #710

SooR opened this issue Apr 2, 2021 · 1 comment · May be fixed by #754

Comments

@SooR
Copy link

SooR commented Apr 2, 2021

numeral(243.7).value() => 243.7
numeral('243,7').value() => 243.7
numeral('243.7').value() => 2437 // Wrong

Why?

@z-yakdi
Copy link

z-yakdi commented Apr 14, 2021

Also happened to me, I had to convert the string to number using parseFloat in order to get the right value.
Looks like this happens when you use a locale that changes the delimiters :

numeral.register('locale', 'fr', {
  delimiters: {
    thousands: ' ',
    decimal: ','
  },
  abbreviations: {
    thousand: 'k',
    million: 'm',
    billion: 'b',
    trillion: 't'
  },
  ordinal: number => number === 1 ? 'er' : 'e',
  currency: { symbol: '€' }
})

numeral.locale('fr')

numeral('243.7').value() // returns 2437 -> Wrong

However it should return the right value (numeral('243.7').value() => 243.7) if you don't use a locale...

@ShayanEmzed ShayanEmzed linked a pull request Dec 24, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants