Re: Question for a REAL expert on casting double to float...
- From: "Bill Reid" <hormelfree@xxxxxxxxxxxxxxxx>
- Date: Sun, 13 Jul 2008 15:20:18 GMT
Ben Bacarisse <ben.usenet@xxxxxxxxx> wrote in message
news:87prphj53c.fsf@xxxxxxxxxxxx
"Bill Reid" <hormelfree@xxxxxxxxxxxxxxxx> writes:saying
Ben Bacarisse <ben.usenet@xxxxxxxxx> wrote in message
news:871w1yjz5p.fsf@xxxxxxxxxxxx
"Bill Reid" <hormelfree@xxxxxxxxxxxxxxxx> writes:
Except it hardly matters in REAL *scanf() functions what you use
as a specifier for integer numbers, but I haven't checked my "fake"
scan_line() for this case (I just use this to assign to an "unsigned"
which has the same sizeof() as "unsigned long" on my system).
This will lead you astray. It is just as wrong with integer types.
It works because on your current implementation the sizes and alignment
requirement of int and long and the same. Try using your scanf to
read into a short using %d.
No thanks, I'll take your word for it (or maybe I WILL try it). In that
case, there is NO equivalent *scanf() specifier, right? So are you
it is impossible to *scanf() into a short? If it is, how do you do
it?
Don't you have a C library manual? It is all documented. Most
systems also have extensions (and some have limitations) so you can't
avoid reading your library's documentation.
No, I can't avoid READING it (and the hallowed C "standard"), but
I absolutely can't MEMORIZE it, particularly when the mnemonics
are as counter-intuitive as using "h" to identify a "short" (of course
to avoid "letter-space" conflicts with the "string" specifier "s").
And of course, virtually NO "C" documentation explains the
ACTUAL ramifications of mismatched arguments and format
specifiers in clear simple language. My compiler documentation
just lists the argument "modifiers" as "optional", meaning of
course, to the "writers" of the documentation, that they aren't a
required part of the legal SYNTAX of a format specifier. Of
course, to a "normal" human being looking for information as
quickly as possible, it means you can safely ignore them...
Actually, it doesn't seem that "hh" is part of MY library's
*scanf() argument modifiers, so I may try that to see what
happens (it's possible it just isn't documented)...
This is probably the heart of my confusion; you can kind of do
anything with integers, but floating-point numbers are "touchier"...
Well it looks like but not quite how you see it. You can't do
anything with ints either. You just got away with whatever you've
tried so far.
They call me "Lucky" down at the club for multiple lottery
winners...
But in fact this is *unlucky* (as I said below). Lucky programmers
get to see their bugs early.
I guess I was lucky that I saw all those precision errors that came
from using the completely useless "float" type, so I never used it
ever again...
---
William Ernest Reid
.
- Follow-Ups:
- References:
- Question for a REAL expert on casting double to float...
- From: Bill Reid
- Re: Question for a REAL expert on casting double to float...
- From: Raymond Martineau
- Re: Question for a REAL expert on casting double to float...
- From: Bill Reid
- Re: Question for a REAL expert on casting double to float...
- From: Ben Bacarisse
- Re: Question for a REAL expert on casting double to float...
- From: Bill Reid
- Re: Question for a REAL expert on casting double to float...
- From: Ben Bacarisse
- Question for a REAL expert on casting double to float...
- Prev by Date: Re: Comment on trim string function please
- Next by Date: Re: Comment on trim string function please
- Previous by thread: Re: Question for a REAL expert on casting double to float...
- Next by thread: Re: Question for a REAL expert on casting double to float...
- Index(es):
Relevant Pages
|