View previous topic :: View next topic |
Author |
Message |
ChandraKota Beginner
Joined: 03 Aug 2006 Posts: 2 Topics: 1
|
Posted: Thu Aug 03, 2006 12:21 am Post subject: Difference between Decimal and Floating |
|
|
Hi All,
From many days, a question is drilling my mind. What is the difference between a Floating point number and a decimal number.. Is it the only representation it differs or also the way the numbers are stored internally matters. I know Single Point floating number is a 32 bit representation of a real number. But on a 32 bit machine or 64 bit machine how does it really matters. I'm not sure whether I'm confusing myself here. _________________ Thanks & Regards
KRC |
|
Back to top |
|
 |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
|
Posted: Thu Aug 03, 2006 7:59 am Post subject: |
|
|
ChandraKota,
If you are talking about DB2 float and deciaml then here is an explanation to the equivalent cobol formats.
Code: |
REAL or FLOAT(n) = COMP-1
1<=n<=21
DOUBLE PRECISION, = COMP-2
or FLOAT(n) 22<=n<=53
DECIMAL(i+d,d) = COMP-3(Packed decimal)
|
COMP-1 refers to short floating-point format and COMP-2 refers to long floating-point format, which occupy 4 and 8 bytes of storage, respectively. The leftmost bit contains the sign and the next 7 bits contain the exponent; the remaining 3 or 7 bytes contain the mantissa. COMP-1 and COMP-2 data items are stored in z900 hexadecimal format.
COMP-3(Packed-decimal) items occupy 1 byte of storage for every two decimal digits you code in the PICTURE description, except that the rightmost byte contains only one digit and the sign. This format is most efficient when you code an odd number of digits in the PICTURE description, so that the leftmost byte is fully used. Packed-decimal items are handled as fixed-point numbers for arithmetic purposes.
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
ChandraKota Beginner
Joined: 03 Aug 2006 Posts: 2 Topics: 1
|
Posted: Fri Aug 04, 2006 7:58 pm Post subject: |
|
|
Thanks Kolusu, your reply is really impressive. So its all about the way, the data is stored . _________________ Thanks & Regards
KRC |
|
Back to top |
|
 |
|
|