Skip to content

yutingkuang/number-format

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

/** *

  • // 預設: 0.2rc //
  • (123456.789) => 123,456.79
  • (123456.123) => 123,456.12
  • (-100) => -100.00
  • // r : 四捨五入 //
  • (456.78, '0.1r') => 456.8
  • (123456.789, '0rc') => 123,457
  • (-456.78, '0r') => -457
  • // c (逗號) //
  • (123456.789, '0c') => 123,456
  • (123456.789, '0cr') => 123,457
  • (123456.789, '7c') => 0,123,456 // 不足位補零
  • // 整數: 數值表位數,負數表示後面位數,0 表示全部 //
  • (123456.789, '') => '' //沒給就是空
  • (123456.789, '.2') => '.78'
  • (123456.789, '0') => 123456
  • (123456.789, '0r') => 123457
  • (123456.789, '-3') => 456
  • (123456.789, '3') => 123456 // 低於顯示位數不處理
  • (123456.789, '7') => 0123456 // 不足位補零
  • (123456.789, '-7') => 123456 // 不處理
  • (123456.789, '7.4c') => 0,123,456.7890
  • (-100.789, '0') => -101
  • // 小數點 //
  • (123456.789, '0.1') => 123456.7
  • (123456.789, '0.1r') => 123456.8
  • (123456.789, '0.1c') => 123,456.7
  • (123456.789, '0.1rc') => 123,456.8
  • (123456.789, '0.2rc') => 123,456.79
  • (123456.789, '0.5c') => 123,456.78900
  • (123456.789, '1.-5') => 123456 // 沒道理的寫法
  • // K (千 //
  • (123456789.123, '0k') => 123456
  • (123456789.123, '-3kr') => 457
  • (123456789.123, '0kc') => 123,456
  • (123456.789, '0.1kr') => 123.5K
  • (123456.789, '0.2k') => 123.45K
  • // M (百萬 //
  • (123456.789, '0m') => 0
  • (123456.789, '0.0m') => 0.123456789
  • (123456.789, '0.1m') => 0.1
  • (123456.789, '0.3m') => 0.123
  • (123456.789, '2.3m') => 00.123
  • // B (十億 //
  • (123456789, '0b') => 0
  • (123456789, '0.1b') => 0.1
  • // a (自帶最大單位 //
  • (123456.789, '0a') => 123K
  • (123456789, '0a') => 123M
  • (123456, '4a') => 0123K
  • (123456789, '0.2a') => 123.46M
  • (1000000000000, '0ac') => 1,000B
  • (1000000000000, '0.2ac') => 1,000.00B
  • // A (自帶完整單位:前面加數字都無效 //
  • (123456.789, 'A') => '123K'
  • (1234567.89, 'Ar') => '1M 235K'
  • (1002307.89, 'A') => '1M 2K'
  • (1000000000000, 'Ac') => '1,000B'
  • (1000000500000, 'Ac') => '1,000B 500K'
  • (1000003500000, 'Ac') => '1,000B 3M 500K'
  • // z (搭配單位符號:零的時候要顯示 //
  • (1000000000000, 'Acz') => '1,000B 0M 0K'
  • (1000000500000, 'Acz') => '1,000B 0M 500K'
  • // 特殊符號 //
  • (123456.789, '+0') => +123457
  • (123456.789, '0.2r%') => 123456.79%
  • (123456.789, '$0.2c') => $123,456.78
  • (1234567.89, '0mM & 0kK') => '1M & 1234K'
  • (123456.789, '0mM,0kK') => 0M,123K
  • (1234567.89, '(2.3mM) & (kcrK)') => '01.234M & 1,235K'
  • (1234567.89, '(0bB,)(-3mM,)(-3kK,)-3.2') => 1M,234K,567.89
  • (1000000500000.89, '(0bcB,(-3mzM,))(0mM,(-3kzK,))(-3kK,)-3.2') => '1,000B,0M,500K,000.89'
  • (3500000.89, '(0bcB,(0mzM,))(0mM,(-3kzK,))(-3kK,)-3.2') => '3M,500K,000.89'
  • (500000.89, '(0bcB,(0mzM,))(0mM,(-3kzK,))(-3kK,)-3.2') => '500K,000.89' */

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%