About Compiler option && IEEE 754



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

About Compiler option && IEEE 754

Postby vinsonzhang » Wed Dec 29, 2010 2:22 pm

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.
vinsonzhang
 
Posts: 5
Joined: Wed Dec 29, 2010 10:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: About Compiler option && IEEE 754

Postby enrico-sorichetti » Wed Dec 29, 2010 2:43 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: About Compiler option && IEEE 754

Postby vinsonzhang » Wed Dec 29, 2010 2:58 pm

I didn't find the answer.

Anyway,Thanks for your reference.
vinsonzhang
 
Posts: 5
Joined: Wed Dec 29, 2010 10:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: About Compiler option && IEEE 754

Postby enrico-sorichetti » Wed Dec 29, 2010 3:14 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: About Compiler option && IEEE 754

Postby vinsonzhang » Wed Dec 29, 2010 3:35 pm

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.
vinsonzhang
 
Posts: 5
Joined: Wed Dec 29, 2010 10:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: About Compiler option && IEEE 754

Postby Robert Sample » Wed Dec 29, 2010 4:03 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: About Compiler option && IEEE 754

Postby vinsonzhang » Wed Dec 29, 2010 6:20 pm

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.
vinsonzhang
 
Posts: 5
Joined: Wed Dec 29, 2010 10:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: About Compiler option && IEEE 754

Postby Robert Sample » Wed Dec 29, 2010 6:56 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: About Compiler option && IEEE 754

Postby mickeywhite » Thu Dec 30, 2010 2:19 am

Google Big Endian Little Endian
mickeywhite
 
Posts: 11
Joined: Tue Nov 02, 2010 8:04 pm
Has thanked: 0 time
Been thanked: 0 time

Re: About Compiler option && IEEE 754

Postby Akatsukami » Thu Dec 30, 2010 3:17 am

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post