Page 1 of 2

About Compiler option && IEEE 754

PostPosted: Wed Dec 29, 2010 2:22 pm
by vinsonzhang
As we all know , we store floating point (COMP-1) in COBOL using IBM HEX format .

However, I know in COBOL for Windows, We can use Compiler Option "FLOAT(NATIVE)" to enable Storing the Float Point using IEEE format.

So My question is Does anyone know the compiler option to enable Storing the Float Point using IEEE format in Enterprise COBOL?

Does it exist or not?

Thank you very much.

Re: About Compiler option && IEEE 754

PostPosted: Wed Dec 29, 2010 2:43 pm
by enrico-sorichetti
what do the cobol manuals tell about it
it is quite easy to find out by Yourself
start from a cobol bookshelf , for example
http://publibz.boulder.ibm.com/cgi-bin/ ... s/IGY3SH40
and search for IEEE

Re: About Compiler option && IEEE 754

PostPosted: Wed Dec 29, 2010 2:58 pm
by vinsonzhang
I didn't find the answer.

Anyway,Thanks for your reference.

Re: About Compiler option && IEEE 754

PostPosted: Wed Dec 29, 2010 3:14 pm
by enrico-sorichetti
my answer was a way to have You exercise Your inference skills!
COBOL as You already noticed stores and uses only IBM hex format
but to provide JAVA interoperability it will automagically convert between the two formats

click on the link I provided,
click on "search documents"
enter IEEE
and two links will spring pointing to the interoperability facilities

Re: About Compiler option && IEEE 754

PostPosted: Wed Dec 29, 2010 3:35 pm
by vinsonzhang
Some precision will be lost when it converts between the two formats.

So I really expect there was some compiler option to control the storing format.

So you mean there is no way to enable COBOL to Storing floating point using IEEE format?

Thank you again.

Re: About Compiler option && IEEE 754

PostPosted: Wed Dec 29, 2010 4:03 pm
by Robert Sample
So you mean there is no way to enable COBOL to Storing floating point using IEEE format?
This is a true and correct statement.

More importantly, WHY WOULD YOU CARE? A floating point value is stored however the compiler writers want it stored -- the actual format used should not be a concern as long as the format retains precision and accuracy.

Re: About Compiler option && IEEE 754

PostPosted: Wed Dec 29, 2010 6:20 pm
by vinsonzhang
Robert Sample wrote:WHY WOULD YOU CARE?


When I convert a floating point "0.001f" from IEEE format to IBM HEX Format,

and then convert it back to IEEE format, the value does not equal "0.001f".

I think this is a severe problem in many application.

So that's why I want to know how to control the storing format.

anyway, Thank you for your reply.

Re: About Compiler option && IEEE 754

PostPosted: Wed Dec 29, 2010 6:56 pm
by Robert Sample
In general, no matter what the internal representation, it is not possible to accurately store floating point numbers since some numbers require more bits (sometimes an infinite number) than are available on any given computer. This is a known issue and programmers deal with it every day. IBM format, IEEE format, any format you care to name has the same issue. Google numerical accuracy sometime and check out some of the 7,460,000 hits that talk about different products and their limits.

Since you have absolutely no control over how the floating point number is stored internally in the computer, you must adjust your program to deal with the reality that not all floating point numbers represent the exact value desired. As I said before, you should not be concerned -- EVER -- with how a particular internal format handles numbers but rather how your application deals with values that are not precisely represented.

Re: About Compiler option && IEEE 754

PostPosted: Thu Dec 30, 2010 2:19 am
by mickeywhite
Google Big Endian Little Endian

Re: About Compiler option && IEEE 754

PostPosted: Thu Dec 30, 2010 3:17 am
by Akatsukami
Robert Sample wrote:In general, no matter what the internal representation, it is not possible to accurately store floating point numbers since some numbers require more bits (sometimes an infinite number) than are available on any given computer.

I believe that this is not entirely the case here. IEEE 754-2008 and IEEE 754-1987 (but not IEEE 754-1985) specify actual decimal floating-point representations. Of course, it is always possible to specify a transcedental number that cannot be accurately specified in a finite number of bits, but 0.001 base-10 is easily represented with absolute accuracy under the newer standards.

If the TS actually needs to be using floating-point numbers, COBOL is probably the worst language available under current implementations of MVS with which to do it. I strongly urge him to look at some other language.