Solved

Very big: Long Addition...

Posted on 2002-03-19
8
196 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 52

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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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 52

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

752 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