Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
Checking the value of a decimal position

I am trying to find the value of the 4th decimal place and check if it is a zero or not. If not I was planning on throwing an error message. For example 2.3189. I need to be able to check the value of the 4th decimal which in this case is 9. This is the code I have thus far. It seemed to be working for majority of cases but for example 1.2570. When I do the check for this number it says that the 0 is not a 0. When I do the same check with 1.2580 it says that the 0 is a 0. Any help with this would be greatly appreciated.

!!(submission && (quantity * 10000 % 10) === 0);
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I'd do regex checking 4th place after '.' to be zero

var number = 0.554156;
/\.[0-9]{3}0/.test(number.toString())
about 4 years ago · Juan Pablo Isaza Report

0

You could make use of javascript expression for accessing the 4th decimal place since modulus operator has precision issues.

const quantity = 1.2570;
console.log(Number(quantity.toFixed(4).split('.')[1][3]));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!