|
|
Up |
|
|
  |
Author: James Van BuskirkJames Van Buskirk Date: May 10, 2008 20:50
Example:
C:\gfortran\clf\negative_boz>type negative_boz.f90
program negative_boz
use ISO_C_BINDING
integer, parameter :: bk8 = selected_int_kind(2)
integer, parameter :: bk16 = selected_int_kind(4)
integer, parameter :: bk32 = selected_int_kind(9)
integer, parameter :: bk64 = selected_int_kind(18)
integer, parameter :: bk128 = selected_int_kind(36)
integer(bk8) i8
integer(bk16) i16
integer(bk32) i32
integer(bk64) i64
integer(bk128) i128
|
| Show full article (4.41Kb) |
|
| | 35 Comments |
|
  |
Author: Gary ScottGary Scott Date: May 10, 2008 21:44
James Van Buskirk wrote:
> Example:
>
> C:\gfortran\clf\negative_boz>type negative_boz.f90
> program negative_boz
> use ISO_C_BINDING
> integer, parameter :: bk8 = selected_int_kind(2)
> integer, parameter :: bk16 = selected_int_kind(4)
> integer, parameter :: bk32 = selected_int_kind(9)
> integer, parameter :: bk64 = selected_int_kind(18)
> integer, parameter :: bk128 = selected_int_kind(36)
> integer(bk8) i8
> integer(bk16) i16
> integer(bk32) i32
> integer(bk64) i64
> integer(bk128) i128
>
> write(*,1) kind(i8), bit_size(i8), range(i8)
> write(*,1) kind(i16), bit_size(i16), range(i16)
> write(*,1) kind(i32), bit_size(i32), range(i32) ...
|
| Show full article (2.96Kb) |
|
| | no comments |
|
  |
Author: Greg LindahlGreg Lindahl Date: May 10, 2008 22:05
In article flpi144.ffdc.sbc.com>,
Gary Scott sbcglobal.net> wrote:
>> Now, in the gfortran manual,
>>
>> http://gcc.gnu.org/onlinedocs/gfortran/BOZ-literal-constants.html#BOZ-literal-constants
>>
>> it says: "Note that initializing an INTEGER variable with a statement
>> such as DATA i/Z'FFFFFFFF'/ will give an integer overflow error
>> rather than the desired result of -1 when i is a 32-bit integer on a
>> system that supports 64-bit integers. The `-fno-range-check' option
>> can be used as a workaround for legacy code that initializes integers
>> in this manner."
>
>I think that if i is a 64 bit integer, then it should be implied that
>Z'FFFFFFFF' is equivalent to Z'00000000FFFFFFFF' (the upper bytes are
>zero. When I assign a bit pattern to an integer, I want that specific
>bit pattern beginning at the lsb.
|
| Show full article (1.30Kb) |
| no comments |
|
  |
Author: Steven G. KarglSteven G. Kargl Date: May 10, 2008 22:14
In article <-f6dnQlekMGc8LvVnZ2dnUVZ_tDinZ2d@ comcast.com>,
"James Van Buskirk" comcast.net> writes:
>
> Now, in the gfortran manual,
>
> http://gcc.gnu.org/onlinedocs/gfortran/BOZ-literal-constants.html#BOZ-literal-constants
>
> it says: "Note that initializing an INTEGER variable with a statement
> such as DATA i/Z'FFFFFFFF'/ will give an integer overflow error
> rather than the desired result of -1 when i is a 32-bit integer on a
> system that supports 64-bit integers. The `-fno-range-check' option
> can be used as a workaround for legacy code that initializes integers
> in this manner."
>
> But in N1723.pdf section 13.3.1 it says "The interpretation of a
> negative integer as a sequence of bits is processor dependent."
From gcc/fortran/primary.c:
|
| Show full article (2.71Kb) |
| no comments |
|
  |
Author: Gary ScottGary Scott Date: May 10, 2008 22:15
Greg Lindahl wrote:
> In article flpi144.ffdc.sbc.com>,
> Gary Scott sbcglobal.net> wrote:
>
>
|
| Show full article (2.08Kb) |
| no comments |
|
  |
Author: Greg LindahlGreg Lindahl Date: May 10, 2008 22:23
In article gnus01.u.washington.edu>,
Steven G. Kargl troutmask.apl.washington.edu> wrote:
> /* In section 5.2.5 and following C567 in the Fortran 2003 standard, we find
> "If a data-stmt-constant is a boz-literal-constant, the corresponding
> variable shall be of type integer. The boz-literal-constant is treated
> as if it were an int-literal-constant with a kind-param that specifies
> the representation method with the largest decimal exponent range
> supported by the processor." */
Woah. Dane-brammage.
Now, mind you, Fortran on a 32-bit processor could support
INTEGER*8. Most C compilers do. Yet more monkey wrenches.
Still, it seems silly to insert a 32/64 bit incompatibility into the
language spec.
-- greg
|
| |
| no comments |
|
  |
Author: James GilesJames Giles Date: May 10, 2008 22:33
Steven G. Kargl wrote:
...
> From gcc/fortran/primary.c:
>
> /* In section 5.2.5 and following C567 in the Fortran 2003 standard,
> we find "If a data-stmt-constant is a boz-literal-constant, the
> corresponding variable shall be of type integer. The
> boz-literal-constant is treated as if it were an
> int-literal-constant with a kind-param that specifies the
> representation method with the largest decimal exponent range
> supported by the processor." */
...
> Neither the F95 nor F2003 standard give any information on
> the interpretation of a BOZ literal constant when it is used in
> any context other than a DATA statement. In F2003, one can do
I can't see how your reconcile these two statements. Suppose the
largest integers your implementation supports are 64-bit, and the
KIND number of such integers is K64. Then the following are identical
in meaning according to the fragment of the standard you quoted yourself:
|
| Show full article (1.59Kb) |
| no comments |
|
  |
Author: Steven G. KarglSteven G. Kargl Date: May 10, 2008 22:36
> In article gnus01.u.washington.edu>,
> Steven G. Kargl troutmask.apl.washington.edu> wrote:
>
>> /* In section 5.2.5 and following C567 in the Fortran 2003 standard, we find
>> "If a data-stmt-constant is a boz-literal-constant, the corresponding
>> variable shall be of type integer. The boz-literal-constant is treated
>> as if it were an int-literal-constant with a kind-param that specifies
>> the representation method with the largest decimal exponent range
>> supported by the processor." */
>
> Woah. Dane-brammage.
>
> Now, mind you, Fortran on a 32-bit processor could support
> INTEGER*8. Most C compilers do. Yet more monkey wrenches.
>
> Still, it seems silly to insert a 32/64 bit incompatibility into the
> language spec.
> ...
|
| Show full article (1.43Kb) |
| no comments |
|
  |
Author: Steven G. KarglSteven G. Kargl Date: May 10, 2008 22:51
In article bgtnsc04-news.ops.worldnet.att.net>,
"James Giles" worldnet.att.net> writes:
> Steven G. Kargl wrote:
> ...
>> From gcc/fortran/primary.c:
>>
>> /* In section 5.2.5 and following C567 in the Fortran 2003 standard,
>> we find "If a data-stmt-constant is a boz-literal-constant, the
>> corresponding variable shall be of type integer. The
>> boz-literal-constant is treated as if it were an
>> int-literal-constant with a kind-param that specifies the
>> representation method with the largest decimal exponent range
>> supported by the processor." */
> ...
>> Neither the F95 nor F2003 standard give any information on
>> the interpretation of a BOZ literal constant when it is used in
>> any context other than a DATA statement....
|
| Show full article (2.38Kb) |
| no comments |
|
  |
|
|
  |
Author: glen herrmannsfeldtglen herrmannsfeldt Date: May 10, 2008 23:26
Steven G. Kargl wrote:
(snip)
> I also suspect that there is some historical baggage, but
> I haven't investigated when/where BOZ became part of some
> flavor of Fortran.
Z came, at least, with OS/360 Fortran IV, which is mostly Fortran 66.
Unlike current BOZ, no apostrophes are used. If used outside a DATA
statement it would be ambiguous. Also, the Z format descriptor.
DATA I/Z1234/
I believe O came from DEC in some form.
It seems that PDP-11 Fortran IV has octal constants with
a preceding quote (") character. Also, the O format descriptor.
I="1234
I believe these could be used anywhere an integer constant
could be used.
-- glen
|
| |
| no comments |
|
|
|
|