Double variable value in excel

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi,

I had a question about how the double variable is used in excel.

When I program in C++ and I assign x = 2; where x is a double the actual
value is
1.999999999 or 2.000000011 but in excel it is exactly the number you assign
it.

I only ask because I was copying code from excel to C++ and part of the code
involved the expression

if (x = 3) then ...

But in C++ you could not use it because x was not always exactly equal to 3
and I ended up using "if (x>2.99 and x<3.001)"

WHy is there a difference?

Thanks
 

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

Single vs Double 3
x-axis scaling 2
Data 1
Scrabble Value calculation for Welsh words 0
VBA - get result from 1
Variable statement 3
Variable substitution 1
VBA - Function Output 2

Back
Top