Hi,
I want to round of the salary amount to the nearest 0.05. eg. if my salary is 1000.23, it should be rounded to 1000.25 and if the salary is 1000.26 it should be rounded off to 1000.30.
The Math.round function is not helpful in the above sceneario.
Suggestions pls
Regards
cmrhema
cmrhema
0
Newbie Poster
Recommended Answers
Jump to PostFor the first case:
If your salary is 1000.23 it has to be 1000.25:
We multiply 1000.23 by 20, round it off to the nearest integer and divide it back by 20 :) ...Edit:: In the second case (if your salary is 1000.26 and it has to rounded …
Jump to PostIf you want 1000.26 to round to 1000.30, you would have to use Math.ceil.
All 7 Replies
mvmalderen
2,072
Postaholic
nmaillet
97
Posting Whiz in Training
ddanbe
2,724
Professional Procrastinator
Featured Poster
avirag
10
Posting Whiz
ddanbe
2,724
Professional Procrastinator
Featured Poster
avirag
10
Posting Whiz
ddanbe
2,724
Professional Procrastinator
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.