Search code examples
delphidelphi-7

what is SQL Server Money equivalent datatype in Delphi


we are working on Delphi 7 and SQL server 2008. SQl server Money Field size is //-922,337,203,685,477.5808 to 922,337,203,685,477.5807

what is equivalent in Delphi? we need to add some validations on Delphi side not to allow size more than sql server money field.


Solution

  • Currency is the equivalent type.

    • It's stored as a 64-bit integer with implied 4 decimal places.
    • It's main advantage over Double is the fact that it provides precise representation of decimal numbers with up to 4 digits. E.g. 0.1 cannot be precisely represented as a Double value. Whereas with Currency, all numbers in the range -922337203685477.5807 .. 922337203685477.5807 can be precisely represented.
    • Note that it has a disadvantage compared to Double in that it supports a range of values comparatively 'close' to zero. Double supports a much larger range by discarding precision beyond 15-16 digits: 2.23e-308 .. 1.79e+308