You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In most locales, for numbers smaller than 100000, a thousand separator is used based on powers of 1000.
This means that if a string is provided with only one dot or comma and there are 3 digits following it, the guesser will treat this number as a whole number; otherwise it will treat it as a float.
The issue here is that if a user input the value like 12.345 and wants it to be interpreted as a float, they would have to explicitly specify the decimal separator.
Do you think it's better to convert 12.345 into an integer, or is it preferable to convert it into a float? Full logic for checking if the value probably is an integer is in NumberValidator class.
Or perhaps someone has an idea for making this rule more flexible?
This logic is causing the most uncertainty for me; otherwise, the DecimalSeparatorGuesser performs quite well in other aspects.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently, if you do not specify a decimal separator, the
Num
helper tries to guess it using the DecimalSeparatorGuesser, which relies on formatting conventions from the Wikipedia article: https://en.wikipedia.org/wiki/Decimal_separator.In most locales, for numbers smaller than 100000, a thousand separator is used based on powers of 1000.
This means that if a string is provided with only one dot or comma and there are 3 digits following it, the guesser will treat this number as a whole number; otherwise it will treat it as a float.
The issue here is that if a user input the value like
12.345
and wants it to be interpreted as a float, they would have to explicitly specify the decimal separator.Do you think it's better to convert
12.345
into an integer, or is it preferable to convert it into a float? Full logic for checking if the value probably is an integer is in NumberValidator class.Or perhaps someone has an idea for making this rule more flexible?
This logic is causing the most uncertainty for me; otherwise, the
DecimalSeparatorGuesser
performs quite well in other aspects.Beta Was this translation helpful? Give feedback.
All reactions