Re: Binary operations in FORTRAN
From: Richard Maine (nospam_at_see.signature)
Date: 08/16/04
- Next message: Paul Van Delst: "Re: helppppp.."
- Previous message: Jeevan: "helppppp.."
- In reply to: Håkan Lane: "Re: Binary operations in FORTRAN"
- Next in thread: Arjen Markus: "Re: Binary operations in FORTRAN"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Paul Van Delst: "Re: helppppp.."
- Previous message: Jeevan: "helppppp.."
- In reply to: Håkan Lane: "Re: Binary operations in FORTRAN"
- Next in thread: Arjen Markus: "Re: Binary operations in FORTRAN"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|