Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    India
    Posts
    22

    Arrow Unanswered: 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

  2. #2
    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.nl/vspickelen...s/LargeInt.htm (haven't tried it myself)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •