Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OverFlow Error

Posted on 2006-06-15
10
Medium Priority
?
200 Views
Last Modified: 2010-04-30
I need to store decimal point values in a variable, the range of values is 19.999999 to 0.999999...

The problem is what type do I declare my variable as because....

Integer and Long no good as it rounds decimal places...

Decimal has a range of "For numbers with 28 decimal places, the range is
+/-7.9228162514264337593543950335. The smallest possible non-zero number is 0.0000000000000000000000000001."

Single has a range of "-3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values."
 
Variant is the same as "Same range as Double for numerics."  

Thanks Ian

0
Comment
Question by:ISC
[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
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16909757
You can store the numbers 19.999999 to 0.999999... in doubles. How many significant digits (how accurate) do you need?
0
 
LVL 1

Author Comment

by:ISC
ID: 16909771
At least 2 significant digits and 6 decimal places...

I tried this but I get an overflow error...


Ian
0
 
LVL 1

Author Comment

by:ISC
ID: 16909817
The calculation causing the problem ss...

   Dim k As Double
       
    k = m_objAccrualRecord.m_intNumberOfDays * 100 * l_dblDailyAccrualTotal

This caused an overflow, however if I change the code to...

  Dim k As Double
       
        k = CDbl(m_objAccrualRecord.m_intNumberOfDays) * CDbl(100) * l_dblDailyAccrualTotal

It works....!
0
Independent Software Vendors: 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 76

Expert Comment

by:GrahamSkan
ID: 16909872
There is a buglet in VB. The calculation can start off assuming (for speed) that it is using integers, only to be confounded later on by a number too big to fit into its temporary location.
0
 
LVL 1

Author Comment

by:ISC
ID: 16909879
Thanks I did not know that...!
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 16910426
how about


k = l_dblDailyAccrualTotal * 100.0 * m_objAccrualRecord.m_intNumberOfDays
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 16910501
or


k = m_objAccrualRecord.m_intNumberOfDays * 100.0 * l_dblDailyAccrualTotal
0
 
LVL 1

Author Comment

by:ISC
ID: 16918579
My solution was to use CDbl( ) in the formula this worked and stopped the overflow error...!

 Dim k As Double
       
        k = CDbl(m_objAccrualRecord.m_intNumberOfDays) * CDbl(100) * l_dblDailyAccrualTotal
0
 

Accepted Solution

by:
RomMod earned 0 total points
ID: 16970578
Question closed - 500 points refunded.

Best regards,
RomMod
Experts Exchange
Community Support 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 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…
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…
Suggested Courses

609 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