当前位置:网站首页>JS to realize the number to amount price thousand separator
JS to realize the number to amount price thousand separator
2022-07-26 14:49:00 【spring-java】
Go straight to the code :
function format_with_mod(number) {
let n = number;
let r = '';
let temp = '';
do {
// Modulus value , Used to get the top three digits , There may be decimals here
mod = n % 1000;
// Is the value greater than 1, It's a condition to continue
n = n / 1000;
// High three position
temp = ~~mod;
// 1. fill : n > 1 The cycle is not over , Just fill it with, for example 1 => 001
// Otherwise temp = ~~mod When , 1 001, Will become "11"
// 2. Splicing “,”
r = (n >= 1 ? `${temp}`.padStart(3, '0') : temp) + (!!r ? ',' + r : '');
} while (n >= 1);
const strNumber = number + '';
let index = strNumber.indexOf('.');
// Splice decimal parts
if (index >= 0) {
r += strNumber.substring(index);
}
return r;
}
边栏推荐
- sp导出贴图到maya
- Low power multi-channel wfas1431 wireless data acquisition and transmission instrument operation process description
- unity透明通道的小技巧
- The difference between torch.nn and torch.nn.functional in pytorch
- SA-Siam:用于实时目标跟踪的孪生网络
- selenium 代码存放
- LeetCode659.分割数组为连续子序列 (哈希表)
- VBA 上传图片
- Create root permission virtual environment
- 【愚公系列】2022年7月 Go教学课程 017-分支结构之IF
猜你喜欢

Flask send_ Absolute path traversal caused by file function

10 schemes to ensure interface data security

What is the problem of the time series database that has been developed for 5 years?
![Matlab solution of [analysis of variance]](/img/30/638c4671c3e37b7ce999c6c98e3700.png)
Matlab solution of [analysis of variance]

PyTorch中 nn.Conv2d与nn.ConvTranspose2d函数的用法

How to evaluate the test quality?

当AI邂逅生命健康,华为云为他们搭建三座桥

保证接口数据安全的10种方案

C# 常用功能整合

SiamRPN:建议区域网络与孪生网络
随机推荐
GOM登录器配置免费版生成图文教程
Figure introduction to neural network core dataset
31. Opinion-based Relational Pivoting forCross-domain Aspect Term Extraction 阅读笔记
js 实现数字转金额价格千分符
[ostep] 04 virtualized CPU - process scheduling strategy
什么是传输层协议TCP/UDP???
【使用工具条绘图】
智能家居行业发展,密切关注边缘计算和小程序容器技术
保证接口数据安全的10种方案
JS wave animation effect menu style
C# NanUI 相关功能整合
[ostep] 02 virtualized CPU - process
One stop monitoring of the software and hardware infrastructure of the whole university, and Suzhou University replaces PostgreSQL with time series database
sp导出贴图到maya
Would you please tell me if there is a way for Flink SQL not to output update_ before?
Usage of nn.conv2d and nn.convtranspose2d functions in pytorch
C nanui related function integration
10 schemes to ensure interface data security
Flask send_ Absolute path traversal caused by file function
Network pictures are transferred locally, causing the kernel to exit