I am writing a program that will automatically check & pay off the amount I owe on my credit card. Since it takes a few days to process payment, I am saving the value I owed to a .txt file on my PC, then when the script goes off the following day, it will check the text file and see if the amount I currently owe is the same as the amount I owed yesterday. If it is the same it will not pay again.
Since I am not performing mathematical operations on the floats, it may be fine to compare. But I am just concerned because everyone says comparing floats is unreliable.
The exact steps I'm performing:
- Copy the amount owing from the text on the website (ex: 237.55)
- Read the contents of my text file, and assign it to a variable (ex: 237.55)
- Compare the two floats (==) and if they are equal, I exit the program.
Could this potentially cause issues?
Since I am not performing mathematical operations on the floats, it may be fine to compare. But I am just concerned because everyone says comparing floats is unreliable.
The exact steps I'm performing:
- Copy the amount owing from the text on the website (ex: 237.55)
- Read the contents of my text file, and assign it to a variable (ex: 237.55)
- Compare the two floats (==) and if they are equal, I exit the program.
Could this potentially cause issues?