MikeMcl / bignumber.js

A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
http://mikemcl.github.io/bignumber.js
MIT License
6.63k stars 743 forks source link

Minus sign in formatted strings #357

Closed szgabsz91 closed 1 year ago

szgabsz91 commented 1 year ago

The following methods format the BigNumber instance into a string:

If the BigNumber instance is negative, these methods use the U+002D character (hyphen-minus) as the minus sign.

However, if I'm correct, it would be better to use the U+2212 character (minus sign), as it is visually and semantically a better option for this use case.

If this change request is accepted, I think I could also provide a PR if it helps.

Thank you!

MikeMcl commented 1 year ago

Interesting, but the JavaScript parser doesn't recognise it appropiately so it doesn't seem practical to make the change.

const log = console.log;

log(Number('\u22123'))     // NaN
log(Number('−3'))          // NaN

log(Number('\u002d3'))     // -3
log(Number('-3'))          // -3
szgabsz91 commented 1 year ago

I didn't know that the output of these methods need to be handled correctly by the Number constructor, but if this is a requirement, then I guess this will remain as it is. Thanks for the quick answer!