Re: Binary operations in FORTRAN

From: Richard Maine (nospam_at_see.signature)
Date: 08/16/04


Date: 16 Aug 2004 11:02:39 -0700

Håkan Lane <Hakan.NOLane@SPAMsem.PLEASEchalmers.se> writes:

> I think you may be wrong about this one. I believe the person wants to
> go from 7 to 00000111. Don't you?

Well... that doesn't make any sense to me without more
context. As someone else mentioned, such "conversions" are
fundamentally about representations; its is hard to meaningfully
express the question without talking about representations.
You just wrote 7 and 00000111, but I can't tell what you mean
by that?

In particular, the 0000111 part. If you just mean that as a
mathematical value in base 2, then it is the same value as 7;
no "conversion" needed.

If there is some notion that the language actually has separate
representations for binary and decimal iintegers, then that
notion is incorrect. (F90 allows the possibility of such a
thing, but doesn't specifically require it, and I know of no
current compilers that support it).

The one way that I could interpret that statement reasonably
would be if the 00000111 were a character string. Yes, one
could meaningfully convert an integer value into an equivalent
character string representation of the value using the
characters "0" and "1" to represent binary digits. If that
does happen to be the question, then an internal write using
B format would work in f90 or later.

I'd have probably guessed that the poster was asking how to
convert from a decimal string representation into a (binary)
integer reepresentation, in which case, the answer would be
(as shown elsewhere) an internal read with an I format
(or list-directed would work in f90 or later). That's an
awfully common question here, so I'd guess this to be just
another case of it.

But I suppose that either interpretation is possible. I just
thought that your interpretation needed further interpretation
before I could understand it (assuming that I did correctly
figure it out).

-- 
Richard Maine                       |  Good judgment comes from experience;
email: my first.last at org.domain  |  experience comes from bad judgment.
org: nasa, domain: gov              |        -- Mark Twain


Relevant Pages

  • Re: Null terminated strings: bad or good?
    ... value that an expression with the type size_t (such as a sizeof expression) ... That definitely sounds like a very unorthodox interpretation ... a conversion from size_t to size_t is not supposed to change the value ...
    (comp.std.c)
  • Re: type writers and tooth aches II
    ... > But you are forgetting that that whole interpretation is a result of ... if my representations get out of sync with the world, ... > nutrition, a body to interface them with the environment, sensory input ... It's justified by the fact that that the brain use representations, ...
    (comp.ai.philosophy)
  • Re: Hex--->Dec!
    ... The &H is needed to satisfy VB's syntax rules to identify the string "A" ... the octal equivalent of 10 is 12 which can be computed using ... You're confusing internal and external representations, ... the interpretation and presentation as desired. ...
    (microsoft.public.vb.general.discussion)
  • Trap representations in the absence of padding bits
    ... representations are not interpreted at all doesn't change that. ... notation" does not mention trap representations. ... padding bits the definition of "pure binary notation" would not ... My interpretation differs from yours only in that I ...
    (comp.lang.c)
  • Three questions about signed/unsigned type representations
    ... , and 4.7 (Integral conversions). ... representations of these values that are common to both types (i.e. ... or there is really no word in the Standard about ... Imagine we use 2 bits to represent unsigned int, ...
    (comp.lang.cpp)