Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29407 Discussions

How Do I Make Numerical Constants 8-byte?

jackosullivan1
1,049 Views

Is there some switch I can throw in IVF10 that will force a "1.0" in the source codeto be an 8-byte number?

Or do I have to replace all of my "1.0"s with "1.0D0"s? Or with a variable named "one" that I have defined somewhere as one=1.0D0?

I've already set Default REAL to 8-byte, but the 1.0 comes out in the debugger-hover as 1.000000 not the 1.000000000000000 that I need to use.

Thanks very much and God bless!

Jack

0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,049 Views
If you set the /real_size:64 option to make default real 8 bytes, that should do it. Here's a test. Compile and run this program with that option:

print *, kind(1.0)
end

If it prints 8, then the switch works. However, I don't see how you can hover over a constant and get a display, so you must have assigned the value to a variable. How is that variable declared?
0 Kudos
jackosullivan1
1,049 Views

Steve,

Through the MSVS (C++).NET 2003 interface, I have specified "Default REAL kind 8(/real_size:64)".

kind(1.0) does indeed come out as 8, as does kind(1.)

However, since when in debug mode,the MSVS evaluates expressions that are selected, I would then expect a selected"1." to show as "1.000000000000000" (+ or minus a zero), but what I do get when I select "1." is:

"1.=1.000000"

which also appears in the Watch if I "watch" 1.0. If I watch 1.0D0, it shows as 1.000000000000000.Neitheritem showsa Type. Looks like another MS debugger flaw -- or at least an imperfection!

Anyway, thanks for cluing me in as to how I can check the result, and thanks -- to you and whomever --for making the Default REAL kind apply to numbers as well as variables. I'm changing my whole program to DP (8-byte) and it would be a real pain to have to replace all the numbers.

Thanks again and God bless!

Jack

0 Kudos
Steven_L_Intel1
Employee
1,049 Views
I would never have thought to "watch" 1.0. In any event, the debugger has no clue that you changed the kind of default real when evaluating constants. If you watch a variable of type REAL then you should see double-precision values because the compiler changed the kind of the variable.

It is still not clear to me what you're trying to do in the debugger and what the real problem is.
0 Kudos
jackosullivan1
1,049 Views

Bottom line, I'm trying to assure that when I say, for example,

x_8= 1.2-y_8

I'm really getting 1.200000000000000 - y_8, and not 1.200000zzzzzzzzz - y_8, where the z's are some indeterminate fill-in caused by a 4-byte 1.2 being upped to an 8-byte representatiion.

From what you have said above, and from the kind(1.2) being 8, it looks like my fears have been unfounded.

Thanks again, and God bless!
Jack

0 Kudos
davidspurr
Beginner
1,049 Views
Possibly

x_8 = 1.2_8 - y_8

David
0 Kudos
Steven_L_Intel1
Employee
1,048 Views
Note that there is no such syntax as x_8 - that would be a variable named X_8 and nothing that forces X to kind 8. You have to ensure that the variables are declared to the type and kind you want.
0 Kudos
Jeffrey_A_Intel
Employee
1,049 Views

I'm really getting 1.200000000000000 - y_8, and not 1.200000zzzzzzzzz - y_8, where the z's are some indeterminate fill-in caused by a 4-byte 1.2 being upped to an 8-byte representatiion.

Note that when anarrower type is promoted to a wider type, "indeterminate fill-in" is never added. The value of the wider type is that which is closest to the value of the narrower type. In the case of promoting from single-precision floating-point to double-precision, this always means that 0-bits are added. However, converting a single-precsion 1.2 to double-precision does not give the sameresult as 1.2D0.

0 Kudos
Reply