In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to use Js's Decimal type". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the Decimal type of Js.
Decimal is a data type of SQLServer, MySql and other databases, does not belong to the floating point type, and can be defined as the integer part and the decimal part of the digits. The use of exact decimal types can not only ensure more accurate data calculation, but also save storage space.
Decimal import file
About npm instruction reference
/ * * Node.js*/$npminstall--savedecimal.jsvarDecimal=require ('decimal.js'); / * * ES6 module mode * / import {Decimal} when from'decimal.js';// was first joined, IDEA may not have responded, so it will be grayed out. It will be fine after a while.
The use of Decimal
/ / addition operation vara=0.13;varb=0.25;console.log ('addition operation aplanetta (newDecimal (b); console.log (' using Decimaljsa+b=',newDecimal (a) .add (newDecimal (b)). ToNumber ()); / / subtraction vara=1.0;varb=0.99console.log ('direct subtraction operation a subtraction operation, aantha bauhinia); console.log (' using Decimaljsa-b=',newDecimal (a) .sub (newDecimal (b)). ToNumber (). ToFixed (2) / / preserve two-digit data / / multiply vara=1.01;varb=1.02;console.log ('direct multiplication adirectmultiplication adirectmultiplication); console.log (' use Decimaljsa*b=',newDecimal (a) .mul (newDecimal (b)). ToNumber ()); / / division vara=0.033;varb=10;console.log ('direct division operation a toNumber (b)); console.log (' use Decimaljsa/b=',newDecimal (a) .div (newDecimal (b)). ToNumber ())
At this point, I believe you have a deeper understanding of "how to use the Decimal type of Js". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.