We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there
I was doing a IHM ( interface human-machine) for a Automation and Control project (I'm a student and new to p5), where I needed to fill a tank with a liquid of random pH, then I need to add Sulfuric Acid or Caustic Soda to make the pH 7. But I was getting the same error almost everytime I ran the program, the pH never reached 7 because of a decimal imprecision (which I was adding 0.3pH/sec or reducing it 0.1pH/sec). But I noticed that the problem wasn't in my code, but in the math of p5.
I've solved my problem, but I wanted to report the existence of it here...
SS of my project and the part of the code where it calculated the pH of the liquid:
To prove the problem existed I've created a simple program (subtracting a decimal [0.1] from a whole number [20] ) :
Sorry for my bad English (and the poorly written post, first time here...)
Comments
This is a programming FAQ and not specific to p5. Search 'floating point precision'...
https://forum.Processing.org/two/discussions/tagged/float
Screenshots not showing up, converted to links
Screenshots of code are not helpful. Just paste the text.