to_large_decimal
TABLE OF CONTENTS
Convert a string to a specified number format for long decimal numbers
Definition
number to_large_decimal(string $text, string $culture)
Converts a string to a number, either floating-point or an integer, depending on the format. $culture defines the formatting of the string, namely the thousands separator and the decimal sign.
to_large_decimal supports converting decimal numbers of up to 17 digits in total.
Parameters
string $text
A string to convert to a number. A number is returned with no changes, while other input types will return null with no error.
string $culture
Define the thousands separator and the decimal sign according to a culture. The culture tag consists of a combination of a language and region tag, e.g., en-US.
Returns
number
If $text is a number, returns $text. If $text is a string, it's read as a number in accordance with the $culture specifier, and returned in its number representation. Other input types yield null output with no error.
Examples
{
"numPoint": "1.2",
"longNum": "1.23456789012",
"veryLongNum": "1.2345678901234567890123456789012"
}{
a: to_large_decimal('1.2', 'en-US'),
b: to_large_decimal('1.2', 'en-DK'),
c: to_large_decimal('1,2', 'en-US'),
d: to_large_decimal('1,2', 'en-DK'),
e: to_large_decimal(`1.2`, 'en-US'),
f: to_large_decimal(`1.2`, 'en-DK'),
g: to_large_decimal(numPoint, 'en-US'),
h: to_large_decimal(longNum, 'en-US'),
i: to_large_decimal(veryLongNum, 'en-US'),
j: to_large_decimal(`null`, 'en-US'),
k: to_large_decimal([`0`], 'en-US')
}{
"a": 1.2,
"b": 12,
"c": 12,
"d": 1.2,
"e": 1.2,
"f": 1.2,
"g": 1.2,
"h": 1.23456789012,
"i": 1.2345678901234567,
"j": null,
"k": null
}Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article