Division Error

  • Thread starter Thread starter Guest
  • Start date Start date
Because the integer 500 divided by the integer 2000 returns the integer 0.
Default math rules.

To get a non-zero value:

decimal pct2 = ((decimal) 500 / (decimal) 2000) * (decimal) 100;

- or -

decimal pct2 = (500d / 2000d) * 100d;

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

mystery 2.3 4
Division by Zero Error 1
Access Running Balance in Access 1
The Division 7
Random numbers and division 3
Division 2
question on re-formatting a report 1
Decimal Alias values return as zero? 5

Back
Top