percent

I just want to say that:

1
2
3
4
  if(1 <= relay && relay <= 5)
  {
     tax_rate = 1%;
  }


I don't need to compute a percentage; I just need to say for that
condition tax_rate = 1%; how do I express 1% so that the compiler
understands
1% of 100 = 1.

0.01 * 100 = 1.

Thus:

1
2
3
4
  if(1 <= relay && relay <= 5)
  {
     tax_rate = 0.01;
  }
thanks
To convert back for other use:

 
std::cout << tax_rate * 100 << "%";


Topic archived. No new replies allowed.