# KnowledgeBase Archive

## Q51414: Internal Format of CURRENCY Data Type in BASIC PDS 7.00

``````Article: Q51414
Product(s): See article
Version(s): 7.00 7.10 | 7.00 7.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_basic

The CURRENCY data type available in Microsoft BASIC Compiler versions
7.00 and 7.10 for MS-DOS and OS/2 is an 8-byte signed integer scaled
by 10,000. This allows a variable of the CURRENCY type to have a range
of

(2 ^ 63 -1) / 10,000  =  +922337203685477.5807

to

(2 ^ 63) / 10,000   =  -922337203685477.5808

Up to 19 digits are allowed, with no more than 4 digits to the right
of the decimal point.

Because the CURRENCY type is scaled by 10,000, its internal
representation is the actual value multiplied by 10,000. For instance,
a CURRENCY variable holding the value 0.0001 will be stored as
follows:

HIGH BYTE                                                     LOW BYTE
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001

As with ordinary INTEGERs, the higher byte is stored at the higher
memory address so that once you find the address of the variable, you
will find the low byte there, the second byte stored above, the third
byte above that, etc. The example program below displays the
hexadecimal machine representation for a CURRENCY data type variable
whose value is INPUT from the keyboard.

Sample Code:

'******************************************************************
'     Sample program to display machine representation of the     *
'     CURRENCY data type (8-byte scaled INTEGER)                  *
'******************************************************************
CLS
DO UNTIL INKEY\$ = CHR\$(27)
PRINT "Enter a CURRENCY value.  The machine representation will be "
PRINT "displayed in Hex"
INPUT a@                   ' "@" is the CURRENCY data type suffix.

FOR i% = 7 TO 0 STEP -1
PRINT HEX\$(PEEK(address% + i%)); "  ";  ' Display representation
NEXT i%                                    ' in normal Low-Byte to
' the right form.
PRINT
PRINT "press a key to continue, Esc to EXIT"
SLEEP
LOOP
``````

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.