[LC++]a bit [OT]: float-dificulty

Julien Claassen julien at c-lab.de
Sat Jul 22 22:21:04 UTC 2006

Hi everyone!
  I try to increase/decrase a floating-point value by a fixed amount like
  if ((its_value + incrase_val) <= its_max)
    its_value += increase_va;
   // some error
  But it doesn't work properly. its_max is set to 1.0 and it increases only up
to 0.9 and if I set the value to 1.0 it only decreases up to 0.1 not 0.0.
  I know there's floating-point inprecision to take into account. But how to
avoid this?
  Anyone any idea? I am grateful for everything...
  Kindest regards

Music was my first love and it will be my last (John Miles)

======== FIND MY WEB-PROJECT AT: ========
http://ltsb.sourceforge.net - the Linux TextBased Studio guide

More information about the tuxCPProgramming mailing list