Phone number formatting with a dot after the country code

108 views Asked by At

My domain registrar asks for a phone number in the following format: +358.401234567 (where 358 is the country code, 40 is the area code and the rest is the local phone number).

To me personally this format is unfamiliar, and I couldn't find it used anywhere other than WHOIS domain information. I was trying to find any reference to this specific format specification, but unsuccessfully. Maybe this format is required by ICANN, but I couldn't find any proof of this. Is this phone number notation standardized?

What is most concerning, is that getting this information back from the registrar's REST API, the value is returned as a float like this: { "phone": 358.401234567 }. Can this lead to rounding errors when storing the value as a float instead of a string?

1

There are 1 answers

1
vinc17 On

You should use a string, not a numeric value for a phone number.

If in any case, you need a numeric value, assuming that the binary64 format (double precision) is used internally on the machine, then, if d ⩽ 15, it is possible to convert a d-digit decimal number to binary64, and you will retrieve the original value if you convert the binary64 number back to a d-digit decimal number. This is because 1+d·log(10)/log(2) ⩽ 53 (where 53 is the precision of binary64). Be careful of the trailing zeros if the number of digits of the phone number is variable.