Solved

Very big: Long Addition...

Posted on 2002-03-19
8
191 Views
Last Modified: 2010-05-02
I have 16 digit max currency numbers,
I need to add these, but I cannot do it, because VB have no supported type for this... bigger than LONG.

   Both + and - values I have...

What Can I do for this? How can I add and display these correctly...

Sample:
Num1: 10,000,000,123
Num2: 15,000,000,450
I wanna add these two number...  (No .00)



0
Comment
Question by:Ege
8 Comments
 
LVL 39

Expert Comment

by:appari
ID: 6879258
if at all its required to do these type of calculations i do this in SQLs. for example in Oracle

select to_char(Num1+Num2) from dual

will return exact calculated value without truncation. then use the returned value and format it using format(returnval,"#,#0")

replace Num1 and Num2 with actual values
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 200 total points
ID: 6879266
Use the currency data type?

optionally try the Double data type as:

Range of double is 1.7E +/- 308 (15 digits).
0
 
LVL 2

Expert Comment

by:ronenr
ID: 6879268
IF I undestand right you can do:

Dim x As Currency
Dim y As Currency

x = 10000000123#
y = 15000000450#

Debug.Print Format(x + y, "#,###")

The datatype currency and double are 8 bytes numbers.

Good luck
0
 
LVL 1

Author Comment

by:Ege
ID: 6879278
:)
I am happy today, and want to spent points! ...
Well, I am very new to VB, and do NOT know data types!

sorry others, it is FCEP... (First Come, Earn Point  like FIFO/FILO) :))

bye...
not: I gave "C" ryancys, It was easy...
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Expert Comment

by:Doodle
ID: 6879282
Use the double data type it can deal with larger values.

Integer 2 bytes     -32,768 to 32,767
Long    4 bytes     -2,147,483,648 to 2,147,483,647
Single  4 bytes    
       -3.402823E38 to -1.401298E-45 for negative
        1.401298E-45 to 3.402823E38 for positive
Double  8 bytes
  -1.79769313486232E308 to -4.94065645841247E-324 (-)      
     4.94065645841247E-324 to 1.79769313486232E308 (+)
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6879292
> It was easy...
Thank for the points But is it me deserve a "C"?
0
 
LVL 1

Author Comment

by:Ege
ID: 6879304
Sorry ryancys,
I though "C" as a HALF POINT...

But it is not!

How can I change this? If not, post a comment to
"point and grade for ryancsys"
and get A :))
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6879795
I have corrected this for you and changed the "C" to an "A".  Thank you ryancys for your additional assistance to Ege here, I will also handle the other question for you.

Just to clarify the grading process, Ege, the points you assign are always the same, but the grade you give has a direct impact on the Expert points awarded.  Example, 100 point question with an A grade = 400 expert points, B grade = 300 and C grade = 200, so quite an impact, not to mention that few at this excellent site feel their assistance is anything less than excellent, and for the most part, I wholeheartedly agree.  

Moondancer - EE Moderator
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now