Re: Long long int's and sprintf

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 06/16/01


On Sat, 16 Jun 2001, Mike Stilson wrote:

> side note: I didn't get them with gcc 2.95.2 complaining about the
> signedness of %Lu or %Ld that I can remember, although I did get the
> errors at comparisons on a few scattered lines.  Did that switch long
> time ago though so I might be forgetting too.

You're right.  I don't know why it doesn't complain about the signedness.
I think it should, especially with -Wall.  But, suffice it to say, it
doesn't warn you about it.

> tested, retested, beat on, fed bogus data, you name it; it works fine.
> (suppose I coulda used digits too, just didn't)

The problem with using digits is that you could have "1234".  Now is this
a number representing

  (1 << 1) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 10)

or if it's an ASCII representation of

  (1 << 54) | (1 << 55) | (1 << 56) | (1 << 57)

assuming that 0-9 follow A-Z in flags[]?  You can't tell.

>         /* I prefer that method to strtoul, suppose it could work though,
>          * but I did have problems with it a few other places.
>          * Since I control the input to it, format isn't a problem.
>          */

strtoul() works for unsigned long int, not unsigned long long int.  Thus,
strtoul() probably won't work.


--
Daniel A. Koepke (dak), dkoepke@circlemud.org
Caveat emptor: I say what I mean and mean what I say.  Listen well.
Caveat venditor: Say what you mean, mean what you say.  Say it well.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST