-
Notifications
You must be signed in to change notification settings - Fork 0
WD JS Number Tools
wdonadelli edited this page Nov 12, 2022
·
17 revisions
When informed factorial or percentage values (Strings), the corresponding mathematical value will be assigned, that is, 10% will be transformed to 0.1 and 3! will be transformed to 6.
The initial value cannot be modified by methods or attributes.
To find the description of the tools presented in this section, it is recommended that you read the following topics:
wd(number).abs
let a = wd(2048.58);
a.abs; /* returns 2048.58 */
let b = wd("-10%");
b.abs; /* returns 0.1 */
wd(number).byte
let a = wd(2048.58);
a.byte; /* returns "2.00kB" */
wd(number).dec
let a = wd(2048.58);
a.dec; /* returns 0.58 */
wd(number).fixed(ldec, lint)
Argument | Type | Mandatory | Description |
---|---|---|---|
ldec |
Integer | No | Number of decimal places to display. (default value 0) |
lint |
Integer | No | The minimum number of integer characters. (default value 0) |
let p = wd(3.456);
p.fixed(); /* returns "3" */
p.fixed(2); /* returns "3.46" */
p.fixed(2,2); /* returns "03.46" */
p.fixed(5,3); /* returns "003.45600" */
wd(number).frac
let a = wd(2048.58);
a.frac; /* returns "2048 29/50" */
wd(number).int
let a = wd(2048.58);
a.int; /* returns 2048 */
wd(number).locale(currency)
Argument | Type | Mandatory | Description |
---|---|---|---|
currency |
String | No | Defines the currency code (ISO 4217). |
If a suitable value for the "currency" argument is given, it will return a monetary value.
let p = wd(1050.456);
/* if wd.lang == "pt-BR": */
p.locale(); /* returns "1.050,456" */
p.locale("BRL"); /* returns "R$ 1.050,46" */
p.locale("USD"); /* returns "US$ 1.050,46" */
/* if wd.lang == "en-US": */
p.locale(); /* returns "1,050.456" */
p.locale("BRL"); /* returns "R$1,050.46" */
p.locale("USD"); /* returns "$1,050.46" */
wd(number).ntype
Possible values for ntype
are (strings):
Value | Example |
---|---|
zero | 0 |
+infinity | Infinity |
-infinity | -Infinity |
+integer | 3 |
-integer | -3 |
+float | 0.3 |
-float | -0.3 |
let a = wd(2048.58);
a.ntype; /* returns "+real" */
wd(number).pow10(width)
Argument | Type | Mandatory | Description |
---|---|---|---|
width |
Number | No | Number of decimal places to display. |
let p = wd(3.456);
p.pow10(); /* returns "3.456 x 10⁺⁰" */
p.pow10(2); /* returns "3.46 x 10⁺⁰" */
wd(number).round(width);
Argument | Type | Mandatory | Description |
---|---|---|---|
width |
Number | No | Number of decimal places to round (default value 0). |
let p = wd(3.456);
p.round(); /* returns 3 */
p.round(2); /* returns 3.46 */
wd(number).str
let a = wd(2048.58);
a.str; /* returns "2.0e+3" */
let b = wd("-10%");
b.str; /* returns "-0.10" */
See test method.
- WD Web Libraries | v4.4.4 | 2023-02-22
- Updated on 2023-02-22
- WD JS Array Tools
- WD JS Date Tools
- WD JS DOM Tools
- WD JS Number Tools
- WD JS Text Tools
- WD JS Time Tools
- WD ATTR Chart Tool
- WD ATTR Click Tool
- WD ATTR CSS Tool
- WD ATTR Data Tool
- WD ATTR Device Tool
- WD ATTR Edit Tool
- WD ATTR Filter Tool
- WD ATTR Full Tool
- WD ATTR Jump Tool
- WD ATTR Lang Tool
- WD ATTR Load Tool
- WD ATTR Mask Tool
- WD ATTR Nav Tool
- WD ATTR NoBubbles Tool
- WD ATTR Output Tool
- WD ATTR Page Tool
- WD ATTR Repeat Tool
- WD ATTR Send Tool
- WD ATTR Set Tool
- WD ATTR Shared Tool
- WD ATTR Slide Tool
- WD ATTR Sort Tool
- WD ATTR Tsort Tool
- WD ATTR Translate Tool
- WD ATTR URL Tool
- WD ATTR Vform Tool