in reply to Re^2: Issue getting value from text file and keep decimal
in thread Issue getting value from text file and keep decimal
The two digits after the decimal points are part of the formatting of the string, but a float contains only the value, without any concept of format or display. So when perl has to extract the value from the string "900000.00" to be able to make mathematic operations on it (the substraction), the formatting information is lost.
The confusion might come from the fact that you think you have a float in the first place, when you have instead a string, because perl will (edit: almost) seemlessly turn one into another to make life easier for you, so although your $main_balance is a string before $main_balance = $main_balance - $debit;, it will have been replaced by a number after that line.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Issue getting value from text file and keep decimal
by jason.jackal (Novice) on Jun 26, 2017 at 15:34 UTC | |
by Eily (Monsignor) on Jun 26, 2017 at 15:56 UTC |