Sign in Join
Wiki copytemporary

Currency: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Currency

OldNewLine
1+The `Currency` type is a real [[Data type|data type]] with 4 digits to the right of the decimal point and a range of -922337203685477.5808 to 922337203685477.5807 . The purpose of the `Currency` data type is to give arithmetic results that exactly correspond to decimal calculations on the input values.
2+
3+Real values are normally stored in the [[Binary numeral system|binary number system]] internally, and calculations are performed in the CPU in binary arithmetic. Since humans desire input and output numbers to be in decimal number format, there must be a conversion made between external decimal numbers and their binary internal representation. As a result of the conversion to/from binary numbers and the calculations being done in binary arithmetic, the results of normal real arithmetic can differ from a decimal arithmetic calculation. This discrepancy is not critical in many applications, but *financial applications* want their arithmetic operations to match a decimal arithmetic calculation. The `currency` data type is designed to give arithmetic results corresponding to decimal arithmetic on the real values given.
4+
5+## See also
6+
7+- [[Function|function]] [`CurrToStr`](https://www.freepascal.org/docs-html/rtl/sysutils/currtostr.html)
8+- function [`FormatCurr`](https://www.freepascal.org/docs-html/rtl/sysutils/formatcurr.html)
9+- function [`StrToCurr`](https://www.freepascal.org/docs-html/rtl/sysutils/strtocurr.html)
10+
11+---
12+*From the Free Pascal wiki, page "Currency", as it stood on 2022-05-26 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history