Solved

Very big: Long Addition...

Posted on 2002-03-19
8
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 51

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 51

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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