Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: sizeof Data types |
| Date | 2016-08-08 11:05 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <noa74c$rv2$1@dont-email.me> (permalink) |
| References | <no34bv$1rus$1@gioia.aioe.org> <no5i6b$fk2$1@dont-email.me> <4ccb69e9-3af1-4bf7-8893-773508c03bf9@googlegroups.com> <no9dgf$a05$1@dont-email.me> |
On 08/08/2016 03:48 AM, David Brown wrote: > On 07/08/16 00:25, jameskuyper@verizon.net wrote: > >> My choice of data type is usually constrained by the interfaces to >> the libraries I have to work with. However, when I'm free of such >> constraints, I use "int" as if it were a short form for int_fast16_t, >> and I use long as if it were a short form for int_least32_t. What >> would you use if you needed one of those two types? >> > > > How about using int_fast16_t when you want a short form for > int_fast16_t, and int_least32_t when you want a short form for > int_least32_t? Because "int" IS shorter than "int_fast16_t", and "int_fast16_t" isn't. > Those types exist (in C99 onwards) not just for consistency with the > other intX_t types, but because they can be useful in getting the most > efficient types with the properties you want. "int" is likely to be as > efficient as "int_fast16_t" for single objects, but if you are using > large arrays then "int_fast16_t" will be faster on most platforms (by > making more efficient use of the cache). "long" will satisfy the > requirements of being at least 32 bits, but "int_least32_t" is likely to > be more efficient in most cases. I would be surprised to see int_fast16_t being significantly faster than int. I'd be less surprised to see int_least32_t being smaller than 'long' - I know that there are platforms where 'long' is 64 bits, and on many of those platforms, int_least32_t will be a 32-bit type. However, I'm used to being surprised, it wouldn't bother me much. If I were aware of such being the case, of course I'd use the size-named types. My preference for "int" and "long" is a minor bit of laziness, not something that I'd let interfere with a significantly better choice, if I were certain it was significantly better.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
sizeof Data types Real Troll <real.troll@trolls.com> - 2016-08-05 18:45 -0400
sizeof Data types jameskuyper@verizon.net - 2016-08-05 17:10 -0700
Re: sizeof Data types raltbos@xs4all.nl (Richard Bos) - 2016-08-06 10:35 +0000
Re: sizeof Data types raltbos@xs4all.nl (Richard Bos) - 2016-08-06 10:36 +0000
Re: sizeof Data types Jean-Marc Bourguet <jm@bourguet.org> - 2016-08-06 22:29 +0200
Re: sizeof Data types Ken Brody <kenbrody@spamcop.net> - 2016-08-09 12:55 -0400
Re: sizeof Data types BartC <bc@freeuk.com> - 2016-08-06 21:43 +0100
Re: sizeof Data types jameskuyper@verizon.net - 2016-08-06 15:25 -0700
Re: sizeof Data types David Brown <david.brown@hesbynett.no> - 2016-08-08 09:48 +0200
Re: sizeof Data types James Kuyper <jameskuyper@verizon.net> - 2016-08-08 11:05 -0400
Re: sizeof Data types David Brown <david.brown@hesbynett.no> - 2016-08-08 17:57 +0200
Re: sizeof Data types supercat@casperkitty.com - 2016-08-08 08:36 -0700
Re: sizeof Data types David Brown <david.brown@hesbynett.no> - 2016-08-08 19:05 +0200
Re: sizeof Data types supercat@casperkitty.com - 2016-08-08 14:09 -0700
Re: sizeof Data types David Brown <david.brown@hesbynett.no> - 2016-08-09 09:38 +0200
Re: sizeof Data types Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-09 11:23 +0100
Re: sizeof Data types Tim Rentsch <txr@alumni.caltech.edu> - 2016-08-12 07:42 -0700
Re: sizeof Data types Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-12 21:38 +0100
Re: sizeof Data types Keith Thompson <kst-u@mib.org> - 2016-08-09 08:12 -0700
Re: sizeof Data types supercat@casperkitty.com - 2016-08-10 10:36 -0700
Re: sizeof Data types Keith Thompson <kst-u@mib.org> - 2016-08-10 11:42 -0700
Re: sizeof Data types Philip Lantz <prl@canterey.us> - 2016-08-11 10:20 -0700
Re: sizeof Data types Keith Thompson <kst-u@mib.org> - 2016-08-11 12:04 -0700
Re: sizeof Data types Tim Rentsch <txr@alumni.caltech.edu> - 2016-08-12 08:22 -0700
Re: sizeof Data types Nobody <nobody@nowhere.invalid> - 2016-08-07 01:32 +0100
Re: sizeof Data types Keith Thompson <kst-u@mib.org> - 2016-08-06 18:10 -0700
Re: sizeof Data types Siri Cruise <chine.bleu@yahoo.com> - 2016-08-06 20:22 -0700
Re: sizeof Data types Ian Collins <ian-news@hotmail.com> - 2016-08-07 15:40 +1200
Re: sizeof Data types Ken Brody <kenbrody@spamcop.net> - 2016-08-09 13:06 -0400
Re: sizeof Data types Siri Cruise <chine.bleu@yahoo.com> - 2016-08-09 12:37 -0700
Re: sizeof Data types Tim Rentsch <txr@alumni.caltech.edu> - 2016-08-11 09:18 -0700
Re: sizeof Data types Siri Cruise <chine.bleu@yahoo.com> - 2016-08-11 11:11 -0700
Re: sizeof Data types Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-08-11 12:26 -0600
Re: sizeof Data types David Brown <david.brown@hesbynett.no> - 2016-08-11 23:31 +0200
Re: sizeof Data types supercat@casperkitty.com - 2016-08-11 14:59 -0700
Re: sizeof Data types Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-08-12 00:15 -0700
Re: sizeof Data types Tim Rentsch <txr@alumni.caltech.edu> - 2016-08-12 08:05 -0700
Re: sizeof Data types John Bode <jfbode1029@gmail.com> - 2016-08-08 12:38 -0700
Re: sizeof Data types Ken Brody <kenbrody@spamcop.net> - 2016-08-09 13:08 -0400
Re: sizeof Data types Keith Thompson <kst-u@mib.org> - 2016-08-09 10:43 -0700
Re: sizeof Data types "James R. Kuyper" <jameskuyper@verizon.net> - 2016-08-09 13:41 -0400
Re: sizeof Data types Ken Brody <kenbrody@spamcop.net> - 2016-08-10 11:51 -0400
Re: sizeof Data types "James R. Kuyper" <jameskuyper@verizon.net> - 2016-08-10 12:35 -0400
Re: sizeof Data types Ken Brody <kenbrody@spamcop.net> - 2016-08-11 11:53 -0400
Re: sizeof Data types "James R. Kuyper" <jameskuyper@verizon.net> - 2016-08-13 11:29 -0400
Re: sizeof Data types supercat@casperkitty.com - 2016-08-13 09:18 -0700
Re: sizeof Data types Keith Thompson <kst-u@mib.org> - 2016-08-10 10:13 -0700
Re: sizeof Data types Ken Brody <kenbrody@spamcop.net> - 2016-08-11 11:56 -0400
Re: sizeof Data types Ken Brody <kenbrody@spamcop.net> - 2016-08-09 12:59 -0400
Re: sizeof Data types "James R. Kuyper" <jameskuyper@verizon.net> - 2016-08-09 13:49 -0400
Re: sizeof Data types Ken Brody <kenbrody@spamcop.net> - 2016-08-10 12:08 -0400
Re: sizeof Data types Keith Thompson <kst-u@mib.org> - 2016-08-09 11:35 -0700
csiph-web