Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18011
Number of posts: 55384

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Rounding off double to certain values Posted by vivalavida on 1 Nov 2010 at 7:16 PM
I am currently developing a program that converts any odd calculated value to an even value for example,
the resultant value i got was 0.05999 or 0.0277, how do i convert these 2 values into a even number like 0.06 and 0.02 respectively?

Report
Re: Rounding off double to certain values Posted by pseudocoder on 2 Nov 2010 at 11:35 PM
you might try something like

double var1 = 0.05999
MsgBox Round(var1, 3)

double var2 = 0.0277
MsgBox Abs(Round(var2 - 0.05, 3))

If your version of VB has them, you might also look into the ceil and floor functions.


Report
Re: Rounding off double to certain values Posted by LynnTEtienne on 8 Nov 2010 at 11:41 PM
I'm actually having the same problem. Anyway, thanks for sharing the code for Rounding off double to certain values. :)


___________
wow gold



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.