Multiplication Of Large Numbers..
I have got a unique problem while handling large number multiplications.I am using Currency datatype for all my multiplications. for example if the first number is 12345678.1234 and the second number is 123345678.1234 and the third number is 1234567.123 .Multiping these 3 nos gives me a error.since Iam involving in the development for an Indonasian Package where the currency handling is more.Please give me some soln at the earliest.Praveen B
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Multiplication Of Large Numbers..
I have got a unique problem while handling large number multiplications.
I am using Currency datatype for all my multiplications. for example if the first number is 12345678.1234 and the second number is 123345678.1234 and the third number is 1234567.123 .Multiping these 3 nos gives me a error.
since Iam involving in the development for an Indonasian Package where the currency handling is more.
Please give me some soln at the earliest.
Praveen B
Large Matrix Multiplication
I am writing a VB6 program for a scientific application that needs to multiply two very large matrices (1000x1000). VB6 is hopelessly slow at this. I have used a Fortran DLL which speeds things up considerably, but is still slow, probably because I am using a simple code without any tricks to do the multiplication. Does anyone know a really fast matrix multiplication routine in VB6, Fortran or C++ that I can use to solve this problem?
Thanks!
Multiplication With 2's Complement Numbers?
Hi, all,
I need to do a multiplication with two 54bit 2's complement numbers and get a final product in a 108bit 2's complement number.
Is it possible to convert a number (may up to 1.0*E40) in double datatype into a 108bit 2's complement number? I always encounter overflow errors.
I need the function to verify the functionality of the IC circuit in my final year project.
Thank you!
Sami
Splitting Large Numbers Into Smaller Numbers
i want to divide a decimal into smaller decimals in an array form.
e.g.
starting with 0.22335566
array(0) = 0.22
array(1) = 0.0033 or 3.3 *102
array(2) = 0.000055 or 5.5*104
etc.
can anyone help?
thanx a million
Very Large Numbers
I'm currently working on a program that uses VERY large numbers, and I need a way to get around overflow errors. The current problem is this line:
Code:
Param1 = X And 4294967295#
where X is anything at all. I need to be able to use "And &HFFFFFFF" on variables a lot in this program, but &HFFFFFFFF returns 1 because longs are signed. Anyone know how to fix this?
Large Numbers
why following gives me overflow error?
Dim I as Long
I = 350 * 350
i also need to multiply this:
I = 150000 * 150000 * 1000000 (same error)
or at least I = 150 * 150 * 1000
PLZ help!
Add Two Large Numbers
i want to multiply two numbers in two textboxes
and give the equation
text3.text=val(text1.text)+val(text2.text)
when i multiply two large numbers
the result will like 34.343434343 + E
is there any other way to multiply large numbers so that i get the exact value
Large Numbers
does anyone know how I can do math algorithms that can handle numbers way bigger than long, double, or currency? I am talking trillions, maybe bigger. If the calculator built into windows can handle them, why can't VB? Help?
Large Numbers
Hi, I'm writing an application in which I need to log the start and end times of an event and the subsequent difference in time time measured in seconds. I have used text boxes for the times (1 for hour, 1 for min etc). Then when all is completed, I check all the boxes and work out the times.
Ideally I just take the start units from the end, and if the result is less than zero, ie starts at 23:58:01 and ends at 00:12:34 then I effectively add 24hours to get the number. However, this doesn't even come into question because unless there is only a few mins difference and the start hour is less than the end, then I get overflow errors.
**
My assumption was that "integer" was < 32k (two bytes) and that "long" was <2b (four bytes).
If this is the case, why do I get overflow errors when a "long" variable is assigned to 86k ??
If long is not 4 bytes, how do deal with decently large numbers ? Does VB have an unsigned long or some other way of manipulating large numbers.
Code Extract:
lngSum = ((CLng(txtFH)  CLng(txtSH)) * 3600) + ((CLng(txtFM)  CLng(txtSM)) * 60) + (CLng(txtFS)  CLng(txtSS))
lngDay = 24 * 3600
If lngSum < 0 Then
lngTotal = lngDay + lngSum
Else
lngTotal = lngSum
End If
MsgBox lngTotal 'Only here as a debug
Thanks
Very Large Numbers
Hi,
I am looking for some functions to do addition, subtraction, multiplication and division for numbers of any length. Can anybody help?
Large Random Numbers
Code:
Public Function Random(Lowerbound As Double, Upperbound As Double) As Double
Randomize
Random = Int(Rnd * Upperbound) + Lowerbound
End Function
Now if I use 'MsgBox Random(50000, 100000)' it will give me numbers bigger than 100000! Any solution to this?
Handling Large Numbers In VB6
Hi to all, i am a new entry and i have already a question for u.
I am implementing a cryptographic software based on some well known algorithms and other code written by myself.
The real problem in vb is handling very large numbers.
I use the following function to determine whenever a number is prime or not (for use in RSA enc) but they works only for smaller numbers.
Public Function IsPrime(ByVal N As Double) As Boolean
If Modulus(SQRN(2, (N  1)), N) = 1 Then
IsPrime = True
Else
IsPrime = False
End If
End Function
Private Function Modulus(ByVal X As Double, Y As Double) As Double
Dim Z As Double
Z = Fix(X / Y)
Modulus = X  (Y * Z)
End Function
Public Function SQRN(X As Double, N As Double) As Double
Dim r As Double
Dim Y As Double
r = 1
Y = X
Do While N > 1
If Modulus(N, 2) <> 0 Then r = r * Y
N = Fix(N / 2)
Y = Y * Y
Loop
r = r * Y
SQRN = r
End Function
There is someone who can help me?
Thank You
Fabio
Work With Large Numbers
I need to be able to devide numbers of at least 13 digits (1 trillion).
However, I constantly get a "Overflow" error. I am using a Long variable type, though I have tried a double as well.
Any suggestions would be greatly appreciated
Working With Very Large Numbers In VB?
I am trying to find the sum of all the digits in the number:
9.33262154439442E+157
How do I access the digits that aren't being shown because of the scientific notation?
Problem With Large Numbers
I am working on a project which involves me doing math and other types of manipulation on numbers that are extremely large. For example when I try to define a variable with the value of 7544824877 as soon as I go to the next line it goes to value of 7544824877# or when I generate a value of 900000000000000 in a calculation it goes to a value of 9E+17, I know that they are the same but when I go an try to do furthur math on them I get errors on the +'s. What do I need to do so that the numbers stay their original value and not change to ...# or to ..E+17 etc.
thanks to all that reply.
Subtracting Large Numbers
Hi there,
The following code currently adds two very large integer numbers (which needs to be up to 60 digits long). But my problem is that I need to be able to subtract two numbers, which can be up to the same length. Can somebody please help me by giving me an idea on how to do this.
Thanks for your help!
Private Sub Form_Load()
Combo1.AddItem "+"
Combo1.AddItem ""
Combo2.AddItem "+"
Combo2.AddItem ""
End Sub
If Combo1.Text = "+" And Combo2.Text = "+" Then
If Len(a) >= Len(b) Then
largestring = a
smallstring = b
Else
largestring = b
smallstring = a
End If
For x = 1 To Len(largestring)
topnumber = Mid(largestring, Len(largestring)  (x  1), 1)
If Len(smallstring) >= x Then
bottomnumber = Mid(smallstring, Len(smallstring)  (x  1), 1)
Else
bottomnumber = ""
End If
lresult = Val(topnumber) + Val(bottomnumber) + Val(scarryover)
sTotalString = Right$(CStr(lresult), 1) & sTotalString
If Len(CStr(lresult)) = 2 Then
scarryover = Left$(CStr(lresult), 1)
Else
scarryover = ""
End If
Next x
Text3.Text = scarryover & sTotalString
End If
End Sub
Very Large Numbers And The Mod Operator
Having a bit of a prob with finding the remainder with REALLY big numbers, I have had a look around the threads and tried the functions. However the problem I have is that the numbers I am getting are currently 25 digits long and will be much larger eventually. DP doesnt seem to put these to enough places to allow for the remainder to be calculated. The mantissa doesnt seem to be large enough. Therefore I get a remainder 0 when it should be one. When I try to store the numbers as strings it conversts them to DP for some reason. Any thoughts?
Calculating Large Numbers
I have to multiply two numbers whose length is Number(25,4)
when i use Double after 15 digits it is being converted into Exponential Form. I am not able to get the precision. Is there any other method to achieve this.
dim x as double
dim y as double
x=123456789012345678901.1234
y=123456789012345678901.1234
I want to store the Result of x*y without losing Data.
Calculating Large Numbers
I have to multiply two numbers whose length is Number(25,4)
when i use Double after 15 digits it is being converted into Exponential Form. I am not able to get the precision. Is there any other method to achieve this.
dim x as double
dim y as double
x=123456789012345678901.1234
y=123456789012345678901.1234
I want to store the Result of x*y without losing Data.
Large Numbers In Access
I need to add some data to an access database, but unfortunately one of the bits of data is a 12 digit number.
Does anyone how I can get this 12 digit number into my table and out using VB?
I have written most of my code dynamically, so using Val(textfield) on the order by is not an option!
Large (135 Digit) Numbers
I want to be able to accurately add, subtract, multiply, and divide large (135 digit) numbers. None of the built in data types will do this. Does anyone have any suggestions?
Computation With Large Numbers In VB
Hi All,
I look forward your help for computing large numbers in VB.
I have to multiply two numbers whose length is Number(25,4)
when i use Double after 15 digits it is being converted into ExponentialForm. I am not able to get the precision. Is there any other method toachieve this.
dim x as double
dim y as double
x=123456789012345678901.1234
y=123456789012345678901.1234
I want to store the Result of x*y without losing Data.
Thanks in advance
 Bala
Computation Of Large Numbers
Dear All,
We have table that containing column qty n(13,4) & rate (25,4) as theapplication requires this much width. During computation of these fieldssay qty*rate  results in exponential form or overflow error. How tohandle the situation? Any suggestion/solution is much appreciated.
Thanks & Regards
Balakumar*
Loosing Precision With Very Large Numbers
OK, I wrote this function to create a 24 character Hex String (FFFF FFFF FFFF FFFF FFFF FFFF Max). Well, supposed to anyway. If it worked...
The Problem I am having is when you get close to it's limits, I start loosing precision. It happens when I take the Input number (maximum of a Decimal) and divide it by my Constant to split the number apart.
The problem is like this.
When I take the MAX Input which is 79,228,162,514,264,337,593,543,950,335 (or anything near that) and divide it with my Const (268435456) I am supposed to get:
295147905179352825855.99999999627
But I get 295147905179352825856 with the code. (It rounds it off)
If I use 79,228,162,514,264,337,593,543,950,334 (1 less) I get
295147905179352825855.99999999
Instead of 295147905179352825855.99999999225 (Like It's supposed to calculate out.
Mind you I have to use the CDec() function...
I can't figure out how to get this working. I have WRACKED by brain... Can anyone help me figure out how to use these large numbers without loosing any precision?
Here is the Function (Don't laugh at my messy code)
Code:
Const MAX = 268435456 ' Hex 10000000
Const MAXDEC = "79228162514264337593543950335" ' Upper Limits of Decimal
Private Function LongHex(strNum As String) As String
'=====================================================================
' The largest value this function can calculate is 79,228,162,514,264,337,593,543,950,335
' Which calculates to FFFF FFFF FFFF FFFF FFFF FFFF (Or supposed to)
'=====================================================================
Dim i As Integer ' Loop variable
Dim Hex1 As Variant ' Left of the decimal point
Dim Hex2 As Variant ' Right of the decimal point
Dim sHex As String ' String to output
On Error Resume Next
' Exit if it's not a number
If Not IsNumeric(strNum) Then
Exit Function
End If
' Get rid of any comma's that may have been inputted
strNum = Replace(strNum, ",", "")
If strNum > MAXDEC Then
Exit Function
End If
' Max will calculate out to 1.0 Split it into two parts, Hex1 and Hex2
' Get the value of anything over MAX
'====================================================
' RIGHT HERE is where I am loosing precision with Large numbers...
'====================================================
Hex1 = CDec(strNum) / MAX
' Give me 28 places to the right of the decimal
Hex1 = Format(Hex1, "#.0000000000000000000000000000")
' Multiply the decimal with max to calculate anything less than Max
Hex2 = CDec(("." & Split(CStr(Hex1), ".")(1)) * MAX)
' Get rid of decimals and Hex the values
For i = 1 To Len(Hex1)
If Mid(Hex1, i, 1) = "." Then
Hex1 = Mid(Hex1, 1, i  1)
Exit For
End If
Next
' Hex the values
' If Hex1 value is larger than MAX (and not ""), Call the function again to break it apart.
If Hex1 > MAX And Hex1 <> "" Then
Hex1 = LongHex(CStr(Hex1))
Else
Hex1 = Hex$(Hex1)
End If
Hex2 = Hex$(Hex2)
' Pad the trailing Hex
Hex2 = Left("0000000", 7  Len(Hex2)) & Hex2
' Combine the hex values
sHex = Hex1 & Hex2
' Trim any leading 0's
For i = 1 To Len(sHex)
If Mid(sHex, i, 1) <> "0" Then
sHex = Mid(sHex, i, Len(sHex)  i + 1)
Exit For
End If
Next
LongHex = sHex
End Function
Thanks
Double And Working With Large Numbers!
I've made a proggy using very large numbers. However, I get an overflow error when calculating with large doubles, even though they are in the "valid" range for doubles. Can't Visual Basic calculate stuff like this:
<vb>
Dim val1 as double
Dim val2 as double
Dim sum as double
val1 = 6.7 * 10^28
val2 = 2.1 * 10^15
sum = val1 + val2
</vb>
I get an error when doing something like this... I also use Xor and Mod, but MSDN says they can calculated doubles as well....
please help...
No Scientific Notation For Large Numbers
Is there a way to stop VB displaying large numbers in scientific notation (eg 1.2322343242E+15)?
I've got the caption of a label set to a value in an excel sheet which happens to be a 16 digit number.
How do i force it to show the full number normally?
Trying To Find A Way To Compute Large Numbers
Hello,
I'm still busy working on my prime number program and i have ran into another problem. I want my program to be able to process large numbers like '4364365475467658658768769879797' for example. Now the maximum capacity of the largest numeric type, named currency, is 922337203685477,5808. Thus trying to place a larger number than the maximum will result into an overflow error.
And im using dynamic currency arrays for the Sieve of Eratosthenes which is also included in my program. A currency array is restricted to using a maximum of 10000000 elements per array, Because i want the Sieve of Eratosthenes to be able to process large numbers aswell, i thought of processing the large number per 10000000 elements.
This is how i do it:
dblDeling = Val(txtInvoer.Text) / 10000000
dblRest = dblDeling  Int(dblDeling)
Opslag = Round(CDbl(dblRest * 10000000), 0)
VermenigVuldiger = Round(dblDeling, 0)
now i know how many times i have to repeat processing the number per 10000000.
then i keep declaring dynamic arrays kind of like this:
for i = 1 to vermenigvuldiger
redim number(10000000 * i to 10000000 * (i+1))
bereken number
next i
But there is a downside to this method, i have discovered that whenever you declare a currency array with borders (2130000000 to 2140000000) it will generate an overflow aswell because the borders are to high...
So this means my program will eventually overflow and i dont like that thought.
So is there perhaps a way through the use of API commands (which im still unfamiliar with ) to designate enough memory to hold a large number or an array with large bounds or allot of elements?
I want my program to be able to process numbers that are 2.2 million characters long (the capacity of a variable string type).
Any idea's?
Thanks in advance
Icescar
Mathematical Problem (Large Numbers)
Hi,
Can anybody explain me (or give me the right address) how to do same main mathematical calculations with numbers greater then Integer and Long can hold (e.g. N= 10 ^ 41324)? Also, in case that you know, how can I calculates: 2 ^ N ?
Thanks in advance.
P.S. I heard that this can be solved by using arrays, but I don’t know how.
Data Type For Large Numbers
Hi
If I want to read a number eg 4,123,456,789 using VB6 what type would I use.
I have tried a long but I think that only goes up to 2,xxx,xxx,xxx and I get overflow error. I have used double but get type mismatch !
thanks
Graham
Putting Commas In Large Numbers
What's the best way to break up a large number with commas?
For example, how would I turn 30892457245 into 30,892,457,245?
Thanks.
Converting LARGE Hex Numbers Into Decimal
Does anyone know of any function to convert a large hex number (held in a string) into a decimal number (held in a string). The hex numbers I am wishing to convert may be from 10  20 digits, this will make a big decimal number that must be held in a string.
Help With Storing Extremely Large Numbers
Dear Members,
I want to store a value which has 80 to 150 Number of digits. The Problem is to store them, could u help me to solve this issue. for example I need to generate 100 Digits long Prime Nos. etc.
THanks
Just A Query... {Large Numbers In The Calculator Screen}
hi everyone
i was wondering, u know if you make a calculator for instance, and if the number get really big, the display says 1.233438 E+10, or summit like that. Is there any way of making the display actually show the entire number, rather then one using E?
Extracting Single Numbers From A Large Number
Hi
My program outputs an angle eg. 267.9135843
I then need to specify the varialbes a, b, c and d as the first 4 digits of this angle,
i.e.
a=2
b=6
c=7
d=9
So that I can then input them into a command string to an external device.
Is there a function in VB that will allow me to do this?
Many Thanks
Math Calculations...Multiplying Large Numbers
Hi all I have a program that does some math, I never knew VB had such a limit (I always thought you were just limited by the size of your variable)
but..
MsgBox 62 * 532
Overflow
Or
Dim Bob as currency
bob = 62*532
Overflow
How do I get this to compute? probably some simple solution.
Multiplication
Why do I get an overflow error on this operation?
Dim lngyPos As Long
lngxPos = 240 * 8192 <???
Multiplication
I have Hscroll1 with min=0 and max=5.
I'll make operation text1=hscroll1.value*10000
But why if value=4 or 5 then i get error message.
Can anybody help me?
Thank before...
VB6 Multiplication Bug ?
hi,
i was trying the following when i encountered an overflow error !
Code:
Private Sub Command1_Click()
Text1.Text = 90 * 600
End Sub
Does anyone know why ??
Multiplication In Vb6
hi i am trying to make a calculator in vb but then realized that i have never stuided multiplication or any type of sums lol....so can any one help me...eg below....
thanks pip..
2 To 12 Multiplication
how do u go about writing a program which displays the multiplication tables 2 to 12 in a text box using a for...next loop in the form load event. could any one tell me how to go about this?
[code]
Multiplication
How do I multiply values in a list box by 100 and put them into another list box.Sounds easy enoughf but can't seem to do it. Thanks in advance
Tom
Multiplication Causes Overflow.
Dont know if anyone can help me with this, basically I have 2 Long variables, both are 8 digits, if I try and multiple them together I get an overflow even if I use a double?
Code:
Private lngKeyMod1 As Long
Private lngKeyMod2 As Long
Public Sub process(tmpKeyMod1 As Long, tmpKeyMod2 As Long)
Dim tmpKeyMod3 As Double
lngKeyMod1 = ((tmpKeyMod1 + tmpKeyMod2) Xor 17185) Xor tmpKeyMod2
tmpKeyMod3 = CDbl(lngKeyMod1 ) * CDbl(lngKeyMod1 ) 'OVERFLOW HERE
lngKeyMod2 = Clng(lngKeyMod3 And 4294967295#) ' I Expect an overflow here to
End Sub
lngKeyMod1 ends up at a value 8 digits long (11,000,000ish)
Anyone know what I can do to use longer numbers?
Date Multiplication
I work with SQL Server and I have a datetime field to store time for a process.
so I have the date 01/01/1900 00:41:38 and I want to multiply the 41:38 by 50 and the and then add it to a date
How can I multiply time ??
Multiplication Table
Dim Row As Integer
Dim Column As Integer
Dim MakeRow As Integer
Dim MakeColumn As Integer
Private Sub cmdMult_Click()
picDisplay.Cls
Row = Val(lblRow)
Column = Val(lblColumn)
For MakeRow = 1 To Row
For MakeColumn = 1 To Column
picDisplay.Print MakeColumn;
Next
picDisplay.Print
Next
End Sub
I made this code to display a multiplication table but I don't seem to know how to muliply the row by the column... The output I get is... if lblRow = 5 and lblColumn = 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
How can I make it go like...
1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16
5 10 15 20
???
Multiplication Table
i have a question for you though, okay, i am trying to make a button that will display, in a listbox, the multiplication tables of 1x1, 1x2 ....2x1, 2x2 ... all the way to 25x25 ... do you think you could help get me started on that, i know it's going to take 2 variables .. and it's going to be a for, next statement, correct? maybe someone can help me out wtih this ... thanks..
Multiplication/division
i wrote a multiplication and division function that can handle very large numbers (hundreds of digits) but i need help making it work with decimal places...and division routine also can't divided a larger number into a smaller number...any help would be useful
