• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in rounding the double value  RSS feed

 
anu sav
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i want the double value rounded up to the nearest 0.05
e.g., if input= 10.37 then output= 10.35
if input=10.33 then output=10.35
can anybody help for this logic ?

Thanks
 
Andrey Kozhanov
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anu sav wrote: . . .
i want the double value rounded up to the nearest 0.05
e.g., if input= 10.37 then output= 10.35 . . .
That is not rounded up.

Remember all floating-point arithmetic, including rounding, is subject to errors of imprecision.
 
anu sav
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys..for quick reply. It worked for me.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!