PDA

Click to See Complete Forum and Search --> : Simple Mathematical Operation - Need Help From Expert


netis
Mar 16th, 2007, 01:16 AM
Hi!

I'm new in this forum. Just wanna ask. How to solve this equation:

I have 3 value (A=13, B=3 and C=4.3333)

The eqution is: 13 / 3 = 4.3333

But when 4.3333 * 3 = 12.9999. How I'm suppose to tell the computer that 12.9999 is equal to A? My problem is more complex than this example. This just an example to simplify my problem situation. Did anybody has an explanation to solve this problem? Thank You in advance for you.

cleverconcepts
Mar 16th, 2007, 03:17 AM
try using the currency data type

dim c1 as currency etc

the problem is that the computer cannot display all fractions properly and so suffers from rouding point errors. the easy answer is to use either currency or decimal datatypes in all situations where fractions are required.

Code Doc
Mar 20th, 2007, 01:20 PM
Let C be defined by A / B , which are both whole numbers, rather that read it in as data. Then C * B will always = A and say good bye to 12.99999999999 etc.

Dim A As Single, B As Single, C As Single

Private Sub Form_Load()
A = 13
B = 3
C = A / B
Label1.Caption = Str(C * B) 'Displays 13
End Sub

netis
Mar 21st, 2007, 09:20 AM
Hi there cleverconcepts and Doctor Ed!

Thanks for your help... I really appreciate it. I'll try your suggestions. I'll give the response back for the knowledge to our forum. Thanks pal.

netis
Mar 30th, 2007, 01:49 AM
OMG.. Thanks guys! Both works! ;-)