If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Double Multiplication Problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-18-04, 08:30
jigar_1676 jigar_1676 is offline
Registered User
 
Join Date: Feb 2004
Location: India
Posts: 22
Arrow Double Multiplication Problem

Hi All,
I have one problem. I will be thankful for your help
I have one text box which accpts maximum 25 numeric digits and on lost event it is calculating and displaying the result in another text box
Private Sub Text1_LostFocus
Dim a as double
a=2
Text2.Text=Format(Text1.Text * Number2, "##############################")
End Sub

Now if I enter 999999999999999999999999999999 in text box and press tab key, it is showing 20000000000000000000000000 insted of 19999999999999999999999998.
Can anybody help me in this
__________________
Regards,
Jigar Bhavsar
Reply With Quote
  #2 (permalink)  
Old 05-26-04, 12:30
Apel Apel is offline
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 228
This is a genaral problem. Double is a floating point data type and thus has a limited precision which you are exceeding. You are actually exceeding it with 999999999999999999999999999999 already. The value in the Textbox is a string, when implically casted to double (hard to calc with strings ) it already gets rounded to 1000000000000000000000000000000. If you really need integer math with such big numbers you need a seperate library like http://www.home.zonnet****/vspickelen...s/LargeInt.htm (haven't tried it myself)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On