将浮点数转换为货币阿根廷比索
Converting float to currency Argentine Peso
阿根廷比索 (ARS) 的货币符号似乎与美元在美国的符号完全相反。 ,
用作小数点分隔符,.
用作千位分隔符。
1121
=> .121,00
1000.5
=> .000,50
85.72
=> ,72
我查看了 numeral
(npm numeral js
),但我无法将浮点数转换为上面指定的货币格式。
这是我尝试过的:
> numeral('87.75').format('[=10=].0,00')
'.7500'
> numeral('87.75').format('[=10=],0.00')
'.75'
> numeral('87.75').format('[=10=],00')
''
> numeral('87.75').format('[=10=].00')
'.75'
> numeral('87.75').format('[=10=],00')
''
> numeral('87.75').format('[=10=].00')
'.75'
> numeral('87.75').format('[=10=],00')
''
> numeral('87.75').format('[=10=],00.00')
'.75'
> numeral('87.75').format('[=10=][.]0.00')
'.8'
> numeral('87.75').format('[=10=][.]0[.]00')
'.8'
> numeral('87.75').format('[=10=][.]0[,]00')
'.75'
> numeral('87.75').format('[=10=][,]0[,]00')
''
这些都是字符串,但不会影响格式。
toLocaleString
可能是您要查找的函数。你可以 read about it here.
下面是一个使用它将数字格式化为阿根廷比索货币的示例:
var value = 1234.56;
var result = value.toLocaleString('es-ar', {
style: 'currency',
currency: 'ARS',
minimumFractionDigits: 2
});
console.log(result); // Prints ".234,56"
您必须创建自己的格式。向下滚动 numeral.js 文档至 'Languages' 部分,查看有关如何定义定界符的示例。
numeral.language('es_ar', {
delimiters: {
thousands: '.',
decimal: ','
},
currency: {
symbol: '$'
}
});
numeral.language('es_ar');
numeral(1087.76).format('[=10=],0.00')
> ".087,76"
阿根廷比索 (ARS) 的货币符号似乎与美元在美国的符号完全相反。 ,
用作小数点分隔符,.
用作千位分隔符。
1121
=>.121,00
1000.5
=>.000,50
85.72
=>,72
我查看了 numeral
(npm numeral js
),但我无法将浮点数转换为上面指定的货币格式。
这是我尝试过的:
> numeral('87.75').format('[=10=].0,00')
'.7500'
> numeral('87.75').format('[=10=],0.00')
'.75'
> numeral('87.75').format('[=10=],00')
''
> numeral('87.75').format('[=10=].00')
'.75'
> numeral('87.75').format('[=10=],00')
''
> numeral('87.75').format('[=10=].00')
'.75'
> numeral('87.75').format('[=10=],00')
''
> numeral('87.75').format('[=10=],00.00')
'.75'
> numeral('87.75').format('[=10=][.]0.00')
'.8'
> numeral('87.75').format('[=10=][.]0[.]00')
'.8'
> numeral('87.75').format('[=10=][.]0[,]00')
'.75'
> numeral('87.75').format('[=10=][,]0[,]00')
''
这些都是字符串,但不会影响格式。
toLocaleString
可能是您要查找的函数。你可以 read about it here.
下面是一个使用它将数字格式化为阿根廷比索货币的示例:
var value = 1234.56;
var result = value.toLocaleString('es-ar', {
style: 'currency',
currency: 'ARS',
minimumFractionDigits: 2
});
console.log(result); // Prints ".234,56"
您必须创建自己的格式。向下滚动 numeral.js 文档至 'Languages' 部分,查看有关如何定义定界符的示例。
numeral.language('es_ar', {
delimiters: {
thousands: '.',
decimal: ','
},
currency: {
symbol: '$'
}
});
numeral.language('es_ar');
numeral(1087.76).format('[=10=],0.00')
> ".087,76"