Class Index | File Index

Classes


Class pv.Format.number

Represents a number format, converting between a number and a string. This class allows numbers to be formatted with variable precision (both for the integral and fractional part of the number), optional thousands grouping, and optional padding. The thousands (",") and decimal (".") separator can be customized.
Defined in: NumberFormat.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Returns a default number format.
Method Summary
Method Attributes Method Name and Description
 
format(x)
 
fractionDigits(min, max)
Sets or gets the minimum and maximum number of fraction digits.
 
integerDigits(min, max)
Sets or gets the minimum and maximum number of integer digits.
 
parse(x)
Parses the specified string as a number.
Class Detail
pv.Format.number()
Returns a default number format.
Returns:
{pv.Format.number} a number format.
Method Detail
{string} format(x)
Parameters:
{number} x
Returns:
{string}

{pv.Format.number} fractionDigits(min, max)
Sets or gets the minimum and maximum number of fraction digits. The controls the number of decimal digits to display after the decimal separator for the fractional part of the number. If the number of digits is smaller than the minimum, the digits are padded; if the number of digits is larger, the fractional part is rounded, showing only the higher-order digits. The default range is [0, 0].

If only one argument is specified to this method, this value is used as both the minimum and maximum number. If no arguments are specified, a two-element array is returned containing the minimum and the maximum.

Parameters:
{number} min Optional
the minimum fraction digits.
{number} max Optional
the maximum fraction digits.
Returns:
{pv.Format.number} this, or the current fraction digits.

{pv.Format.number} integerDigits(min, max)
Sets or gets the minimum and maximum number of integer digits. This controls the number of decimal digits to display before the decimal separator for the integral part of the number. If the number of digits is smaller than the minimum, the digits are padded; if the number of digits is larger, the digits are truncated, showing only the lower-order digits. The default range is [0, Infinity].

If only one argument is specified to this method, this value is used as both the minimum and maximum number. If no arguments are specified, a two-element array is returned containing the minimum and the maximum.

Parameters:
{number} min Optional
the minimum integer digits.
{number} max Optional
the maximum integer digits.
Returns:
{pv.Format.number} this, or the current integer digits.

{number} parse(x)
Parses the specified string as a number. Before parsing, leading and trailing padding is removed. Group separators are also removed, and the decimal separator is replaced with the standard point ("."). The integer part is truncated per the maximum integer digits, and the fraction part is rounded per the maximum fraction digits.
Parameters:
{string} x
the string to parse.
Returns:
{number} the parsed number.

Documentation generated by JsDoc Toolkit 2.3.2 on Fri May 28 2010 10:13:28 GMT-0700 (PDT)