423,680 Members | 2,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,680 IT Pros & Developers. It's quick & easy.

Really big numbers

P: 1
I am trying to create a program that calculates the cost of one atom of an element but when I run the code this line...

Expand|Select|Wrap|Line Numbers
  1. decCostPerSingle = decSampleCost / decNumPerSample
gets an error that says "DivideByZeroException was unhandled" I think it may be because my "decNumPerSample" is somewhere around .00000000000000000000000007985 and I think it is rounding down to zero.

How do I fix this problem.
Feb 13 '16 #1
Share this Question
Share on Google+
1 Reply


P: 27
You're very likely to have sussed this out by now, but I think you'll have to settle for Cost per trillion atoms or some other large number.

Just make sure that you multiply up before you divide thus:
(1000000000000 * decSampleCost) / decNumPerSample.
Mar 3 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.