31,021
edits
| Line 171: | Line 171: | ||
* Screen displayed web pages are UTF8 (for versions prior to 2.5.1, the deprecated $character_set parameter from conf.php file defines output format). | * Screen displayed web pages are UTF8 (for versions prior to 2.5.1, the deprecated $character_set parameter from conf.php file defines output format). | ||
== | == Float numbers, amount and calculation == | ||
With PHP, like other languages (Java for exemple), non integer data (float, real, double) are not reliable for calculation. | |||
Try to make for example | |||
<source lang="php"> | <source lang="php"> | ||
print 239.2 - 229.3 - 9.9; | print 239.2 - 229.3 - 9.9; | ||
</source> | </source> | ||
You wont get zero but a very small decimal number. If you get zero her, you should be able to find other examples that don't work. | |||
Problem of float is general, so a variable that is a result of a calculation using decimal numbers must ALWAYS be cleaned using the function '''price2num()''' with the econd parameter to: 'MU', 'MT' or 'MS' depending on need (see description of function). | |||
<source lang="php"> | <source lang="php"> | ||
print price2num(239.2 - 229.3 - 9.9, 'MT'); | print price2num(239.2 - 229.3 - 9.9, 'MT'); | ||
</source> | </source> | ||
If data manipulated is not an amount, so using MU, MT, MS has no sense, so you must use the function '''round()'''. | |||
== Création de tables == | == Création de tables == | ||