Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Something C might need Date: Sun, 24 Sep 2017 12:12:51 -0700 Organization: None to speak of Lines: 75 Message-ID: References: <1cc86992-d71e-42b9-818f-f883b78e79ce@googlegroups.com> <7ac3b44a-b838-4462-88c8-adcd77d61ce1@googlegroups.com> <87wp4p4sej.fsf@bsb.me.uk> <87k20p3p8s.fsf@bsb.me.uk> <2GDxB.1282792$zs1.548390@fx15.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="f340375e532714dc24c747dfdddc9b11"; logging-data="15024"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19W3yW7h8ndJPTlMfHY91lm" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:LwqhOXPe0J0CRQpeVWADnCbeLSI= sha1:Q1PtHZNC+I0luvkfLIXBFimM3JI= Xref: csiph.com comp.lang.c:120237 bartc writes: > On 24/09/2017 02:41, Keith Thompson wrote: >> bartc writes: >>> On 24/09/2017 01:38, Ben Bacarisse wrote: >>>> bartc writes: >>>> >>>>> On 23/09/2017 20:29, David Kleinecke wrote: >>>> >>>>>> I work from C89 so "long long" isn't part of what I talked >>>>>> about but it is obvious what it means - a value twice as >>>>>> long as a long. >>>>> >>>>> That's what you would think. But not when dealing with C where >>>>> everything has to have an unexpected twist. >>>>> >>>>> long long simply means a type at l[e]ast as wide as a long. >>>> >>>> No it doesn't. You could have find out what it means if you wanted to, >>>> but I expect you'd rather just complain about how it's all so confusing. >>> >>> So, what does it mean then? >> >> The answer to your question is in n1570.pdf. > > Why do you guys do this? [...] > Give me a clue please. LLONG_MIN must be no greater than -9223372036854775807, and LLONG_MAX must be no less than +9223372036854775807, implying that long long must be at least 64 bits. That's the main point you didn't mention. [...] >> Java, as I recall, has fixed sizes for its predefined types. What if I >> want a type that's at least N bits and as efficient as possible? I can >> do that in C. > > What does that even mean? And has anybody ever actually used such a type? In C it's called int_fastN_t, which exists for at least N = 8, 16, 32, and 64. > (How do you say in Ada that you want a type that can represent at least > the range 0 to 16383?) type Whatever is range 0 .. 16383; -- Why do you ask? (Ada's predefined integer types are similar to C's, with Integer, Long_Integer, and so forth. The main difference is that Ada, unlike C, provides a way to define your own integer types with specified ranges.) >>> So, if you're coding for x86, which one, if any, is 32 bits, and no >>> wider, on both Windows and Linux? >> >> int32_t or uint32_t. But you already knew that. > > The context here is the classic pre-C99 which is what the OP is > interested in. Pre-C99 is obsolete. I don't know why the OP is so interested in it. And there are implementations of for pre-C99 implementations (it's one of the easier features of C99 to implement, so it was often provided before full C99 compliance was possible). > And even in C99 and later, int32_t etc is a poor solution. People want > to just write 'int' and be able to use "%d" and "INT_MAX". Does "People" refer to anyone other than you? -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"