首页 > 文档 > nfc()格式化成字符串+千位分隔符
2017
07-21

nfc()格式化成字符串+千位分隔符

Name

nfc()格式化成字符串+千位分隔符

   

Examples

int i = 500000;

String si = nfc(i);

println(si); // Prints “500,000”

float f = 42525.34343;

String fi = nfc(f, 2);

println(fi); // Prints “42,525.34”

 

nfc()格式化成字符串+千位分隔符 - 第1张  | Processing编程艺术

int[] i = { 500000, 4000 };

String[] si = nfc(i);

println(si); // Prints “500,000 4,000”

float[] f = { 42525.34343, 3.14159 };

String[] fi = nfc(f, 2);

println(fi); // Prints “42,525.34 3.14”

Description

Utility function for formatting numbers into strings and placing appropriate commas to mark units of 1000. There are four versions: one for formatting ints, one for formatting an array of ints, one for formatting floats, and one for formatting an array of floats.

The value for the right parameter should always be a positive integer.

For a non-US locale, this will insert periods instead of commas, or whatever is apprioriate for that region.

用于将数字格式化为字符串并将适当的逗号放置到标记单位1000的实用程序函数。有四版本: 一个用于格式化整数, 一个用于格式化整数数组, 一个用于格式化浮动, 另一个用于格式化浮动数组。

 

右参数的值应始终为正整数。

 

对于非美国语言环境, 这将插入句点, 而不是逗号, apprioriate 该区域的任何位置。

Syntax

nfc(nums)

nfc(num)

nfc(nums, right)

nfc(num, right)

Parameters

nums

float[], or int[]: the numbers to format

num

float, or int: the number to format

right

int: number of digits to the right of the decimal point

Returns

String[]

Related

nf()
nfp()
nfs()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。