Elementary question

Elementary question

I have never figured out why is the logical type allows anything other than 1 byte (or really even 1 bit).

So even logical(1) has 7 bits too many, let alone logical(4).

Tim

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

In the beginning (or close to it), all Fortran types were either one "arithmetic storage unit" or two. INTEGER, REAL and LOGICAL were one storage unit, COMPLEX and DOUBLE PRECISION were two. Fortran had no concept of bytes, and in fact, prior to Fortran 77, didn't even have CHARACTER. Therefore, LOGICAL was the same size as INTEGER (and in fact there is a lot of wording in the standard stating this.)

Not until Fortran 90 did the concept of "kind" come around, so that you could have LOGICALs of different sizes. But even then, Fortran had no bit datatype (as it still doesn't today.) Even so, the default LOGICAL type is the same size as default INTEGER and REAL.

For further reading, see my article It's Only Logical.

Steve

Retired 12/31/2016

Thanks,
I will look at your article.
However, if this is a fortran quirk, why so many other lang's also have things like boolean(2).

Similarly, the fact that there is logical(4) in the com server wizid means that this oversized type is not a fortran only quirk.

just curious.

Tim

Fortran now has the ability to specify different kinds (typically sizes) for LOGICAL. Note that Fortran LOGICAL is not the same as Windows return statuses (or C's bool).

I don't understand what problem you see here.

Steve

Retired 12/31/2016

I mostly wonder why Logical(1) is not allowed as a data type in the com server interface.

At the time the COM Server Wizard was written, Automation did not support an equivalent of LOGICAL(1). It may still not.

Steve

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today