Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #23604 > unrolled thread
| Started by | "Ansel" <tinker454@trytospammenowloser.com> |
|---|---|
| First post | 2012-07-23 01:32 -0600 |
| Last post | 2012-08-04 22:54 -0600 |
| Articles | 20 on this page of 107 — 18 participants |
Back to article view | Back to comp.lang.c
Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-23 01:32 -0600
Re: Restricted unsigned integer range would have been better? "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-07-23 01:45 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-24 00:19 -0600
Re: Restricted unsigned integer range would have been better? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-24 11:25 +0100
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-24 16:22 -0600
Re: Restricted unsigned integer range would have been better? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-25 01:53 +0100
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-24 21:43 -0600
Re: Restricted unsigned integer range would have been better? "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-07-24 16:29 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-24 21:53 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-07-24 23:24 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-25 01:12 -0600
Re: Restricted unsigned integer range would have been better? Nobody <nobody@nowhere.com> - 2012-07-23 10:37 +0100
Re: Restricted unsigned integer range would have been better? Andre <lodwig@pathme.de> - 2012-07-23 11:46 +0200
Re: Restricted unsigned integer range would have been better? "BartC" <bc@freeuk.com> - 2012-07-23 11:33 +0100
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-23 23:48 -0600
Re: Restricted unsigned integer range would have been better? "BartC" <bc@freeuk.com> - 2012-07-24 10:43 +0100
Re: Restricted unsigned integer range would have been better? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-07-24 02:58 -0700
Re: Restricted unsigned integer range would have been better? "BartC" <bc@freeuk.com> - 2012-07-24 12:04 +0100
Re: Restricted unsigned integer range would have been better? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-07-24 05:32 -0700
Re: Restricted unsigned integer range would have been better? "BartC" <bc@freeuk.com> - 2012-07-24 14:20 +0100
Re: Restricted unsigned integer range would have been better? "BartC" <bc@freeuk.com> - 2012-07-24 18:41 +0100
Re: Restricted unsigned integer range would have been better? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-07-24 12:37 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-24 16:15 -0600
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-24 16:05 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-07-24 23:28 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-25 01:13 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-07-25 01:26 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-25 05:43 -0600
Re: Restricted unsigned integer range would have been better? David Brown <david@westcontrol.removethisbit.com> - 2012-07-24 15:10 +0200
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-24 16:23 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-07-24 23:40 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-25 01:32 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-07-25 01:29 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-25 05:45 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-07-25 12:35 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-26 00:12 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-07-26 01:42 -0700
Re: Restricted unsigned integer range would have been better? David Brown <david@westcontrol.removethisbit.com> - 2012-07-25 09:31 +0200
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-25 06:28 -0600
Re: Restricted unsigned integer range would have been better? David Brown <david@westcontrol.removethisbit.com> - 2012-07-25 16:28 +0200
Re: Restricted unsigned integer range would have been better? "BartC" <bc@freeuk.com> - 2012-07-25 17:17 +0100
Re: Restricted unsigned integer range would have been better? David Brown <david@westcontrol.removethisbit.com> - 2012-07-26 12:07 +0200
Re: Restricted unsigned integer range would have been better? "BartC" <bc@freeuk.com> - 2012-07-26 14:06 +0100
Re: Restricted unsigned integer range would have been better? James Kuyper <jameskuyper@verizon.net> - 2012-07-26 09:45 -0400
Re: Restricted unsigned integer range would have been better? David Brown <david@westcontrol.removethisbit.com> - 2012-07-30 09:01 +0200
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-26 00:09 -0600
Re: Restricted unsigned integer range would have been better? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-07-26 00:52 -0700
Re: Restricted unsigned integer range would have been better? pete <pfiland@mindspring.com> - 2012-07-26 20:35 -0400
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-26 22:35 -0600
Re: Restricted unsigned integer range would have been better? pete <pfiland@mindspring.com> - 2012-07-27 09:19 -0400
Re: Restricted unsigned integer range would have been better? Les Cargill <lcargill99@comcast.com> - 2012-07-27 12:51 -0500
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-07-27 16:19 -0700
Re: Restricted unsigned integer range would have been better? Les Cargill <lcargill99@comcast.com> - 2012-07-27 18:47 -0500
Re: Restricted unsigned integer range would have been better? David Brown <david@westcontrol.removethisbit.com> - 2012-07-30 09:10 +0200
Re: Restricted unsigned integer range would have been better? Philip Lantz <prl@canterey.us> - 2012-07-31 17:26 -1000
Re: Restricted unsigned integer range would have been better? pete <pfiland@mindspring.com> - 2012-08-01 00:18 -0400
Re: Restricted unsigned integer range would have been better? "io_x" <a@b.c.invalid> - 2012-08-01 10:19 +0200
Re: Restricted unsigned integer range would have been better? David Brown <david@westcontrol.removethisbit.com> - 2012-08-01 10:09 +0200
Re: Restricted unsigned integer range would have been better? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-01 12:51 +0100
Re: Restricted unsigned integer range would have been better? pete <pfiland@mindspring.com> - 2012-08-01 08:18 -0400
Re: Restricted unsigned integer range would have been better? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-01 14:22 +0100
Re: Restricted unsigned integer range would have been better? pete <pfiland@mindspring.com> - 2012-08-01 09:57 -0400
Re: Restricted unsigned integer range would have been better? pete <pfiland@mindspring.com> - 2012-08-01 11:35 -0400
Re: Restricted unsigned integer range would have been better? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 11:43 -0700
Re: Restricted unsigned integer range would have been better? pete <pfiland@mindspring.com> - 2012-09-08 10:13 -0400
Re: Restricted unsigned integer range would have been better? Philip Lantz <prl@canterey.us> - 2012-09-22 23:39 -0700
Re: Restricted unsigned integer range would have been better? Philip Lantz <prl@canterey.us> - 2012-09-22 23:45 -0700
Re: Restricted unsigned integer range would have been better? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-17 13:52 -0800
Re: Restricted unsigned integer range would have been better? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-17 13:45 -0800
Re: Restricted unsigned integer range would have been better? pete <pfiland@mindspring.com> - 2012-12-17 19:51 -0500
Re: Restricted unsigned integer range would have been better? Philip Lantz <prl@canterey.us> - 2012-12-28 11:11 -0800
Re: Restricted unsigned integer range would have been better? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-29 11:31 -0800
Re: Restricted unsigned integer range would have been better? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-12-29 23:59 +0000
Re: Restricted unsigned integer range would have been better? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-02 10:01 -0800
Re: Restricted unsigned integer range would have been better? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2013-01-05 12:00 +0200
Re: Restricted unsigned integer range would have been better? Philip Lantz <prl@canterey.us> - 2013-01-02 13:07 -0800
Re: Restricted unsigned integer range would have been better? Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-03 12:10 -0800
Re: Restricted unsigned integer range would have been better? James Kuyper <jameskuyper@verizon.net> - 2013-01-05 12:26 -0500
Re: Restricted unsigned integer range would have been better? Philip Lantz <prl@canterey.us> - 2012-09-22 23:35 -0700
Re: Restricted unsigned integer range would have been better? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-17 14:02 -0800
Re: Restricted unsigned integer range would have been better? David Brown <david@westcontrol.removethisbit.com> - 2012-08-01 10:06 +0200
Re: Restricted unsigned integer range would have been better? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-01 12:46 +0100
Re: Restricted unsigned integer range would have been better? Philip Lantz <prl@canterey.us> - 2012-08-02 08:19 -1000
Re: Restricted unsigned integer range would have been better? Philip Lantz <prl@canterey.us> - 2012-08-02 08:17 -1000
Re: Restricted unsigned integer range would have been better? David Brown <david@westcontrol.removethisbit.com> - 2012-08-03 08:04 +0200
Re: Restricted unsigned integer range would have been better? "io_x" <a@b.c.invalid> - 2012-08-03 09:40 +0200
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-27 22:27 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-07-28 01:31 -0700
Re: Restricted unsigned integer range would have been better? "BartC" <bc@freeuk.com> - 2012-07-28 10:52 +0100
Re: Restricted unsigned integer range would have been better? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-07-28 03:31 -0700
Re: Restricted unsigned integer range would have been better? pete <pfiland@mindspring.com> - 2012-07-28 00:05 -0400
Re: Restricted unsigned integer range would have been better? Les Cargill <lcargill99@comcast.com> - 2012-07-27 23:22 -0500
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-07-27 22:35 -0600
Re: Restricted unsigned integer range would have been better? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-08-04 08:43 -0700
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-08-04 16:40 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-08-04 22:58 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-08-04 23:10 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-08-05 01:16 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-08-05 02:25 -0700
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-08-05 03:35 -0600
Re: Restricted unsigned integer range would have been better? Keith Thompson <kst-u@mib.org> - 2012-08-05 12:16 -0700
Re: Restricted unsigned integer range would have been better? gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-05 19:56 +0000
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-08-06 01:12 -0600
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-08-06 01:07 -0600
Re: Restricted unsigned integer range would have been better? gazelle@shell.xmission.com (Kenny McCormack) - 2012-08-05 13:33 +0000
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-08-06 01:13 -0600
Re: Restricted unsigned integer range would have been better? "Ansel" <tinker454@trytospammenowloser.com> - 2012-08-04 22:54 -0600
Page 1 of 6 [1] 2 3 4 5 6 Next page →
| From | "Ansel" <tinker454@trytospammenowloser.com> |
|---|---|
| Date | 2012-07-23 01:32 -0600 |
| Subject | Restricted unsigned integer range would have been better? |
| Message-ID | <juiuqb$rau$1@speranza.aioe.org> |
If C's unsigned integer types were designed so that their maximum value was the same as the absolute value of the same width signed integer type's minimum value, wouldn't that automagically elimintate a bunch of erroneous code and simplify programming in C?
[toc] | [next] | [standalone]
| From | "christian.bau" <christian.bau@cbau.wanadoo.co.uk> |
|---|---|
| Date | 2012-07-23 01:45 -0700 |
| Message-ID | <2d5917c0-6c09-4c23-8672-d9aed340d1ea@l5g2000vbo.googlegroups.com> |
| In reply to | #23604 |
On Jul 23, 8:32 am, "Ansel" <tinker...@trytospammenowloser.com> wrote: > If C's unsigned integer types were designed so that their maximum value was > the same as the absolute value of the same width signed integer type's > minimum value, wouldn't that automagically elimintate a bunch of erroneous > code and simplify programming in C? I'm curious to see an example, which you surely will post.
[toc] | [prev] | [next] | [standalone]
| From | "Ansel" <tinker454@trytospammenowloser.com> |
|---|---|
| Date | 2012-07-24 00:19 -0600 |
| Message-ID | <julesm$ke9$1@speranza.aioe.org> |
| In reply to | #23605 |
>"christian.bau" <christian.bau@cbau.wanadoo.co.uk> wrote in message >news:2d5917c0-6c09-4c23-8672-d9aed340d1ea@l5g2000vbo.googlegroups.com... >On Jul 23, 8:32 am, "Ansel" <tinker...@trytospammenowloser.com> wrote: >> If C's unsigned integer types were designed so that their maximum value >> was >> the same as the absolute value of the same width signed integer type's >> minimum value, wouldn't that automagically elimintate a bunch of >> erroneous >> code and simplify programming in C? > >I'm curious to see an example, which you surely will post. Well the obvious one is that you could assign the negative of any unsigned int to an int without a care. It just seems conceptually simpler: less thinking about trivial details in the solution domain required. Maybe not overall though -- I'd have to think about it some more. I'd bet no one even ever considered that way back when. Rather, they probably just thought, "there are 8-bits, so we *must* utilize them". Conceptual simplicity probably never entered anyone's mind. The hardware drove the design. Or so I wonder.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2012-07-24 11:25 +0100 |
| Message-ID | <0.9437614bb6d82b2295aa.20120724112513BST.87vchdtq0m.fsf@bsb.me.uk> |
| In reply to | #23652 |
"Ansel" <tinker454@trytospammenowloser.com> writes: >>"christian.bau" <christian.bau@cbau.wanadoo.co.uk> wrote in message >>news:2d5917c0-6c09-4c23-8672-d9aed340d1ea@l5g2000vbo.googlegroups.com... >>On Jul 23, 8:32 am, "Ansel" <tinker...@trytospammenowloser.com> wrote: >>> If C's unsigned integer types were designed so that their maximum value >>> was >>> the same as the absolute value of the same width signed integer type's >>> minimum value, wouldn't that automagically elimintate a bunch of >>> erroneous >>> code and simplify programming in C? >> >>I'm curious to see an example, which you surely will post. > > Well the obvious one is that you could assign the negative of any unsigned > int to an int without a care. It just seems conceptually simpler: less > thinking about trivial details in the solution domain required. Maybe not > overall though -- I'd have to think about it some more. I'm curious to see an example. <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | "Ansel" <tinker454@trytospammenowloser.com> |
|---|---|
| Date | 2012-07-24 16:22 -0600 |
| Message-ID | <jun79n$2nd$3@speranza.aioe.org> |
| In reply to | #23663 |
"Ben Bacarisse" <ben.usenet@bsb.me.uk> wrote in message news:0.9437614bb6d82b2295aa.20120724112513BST.87vchdtq0m.fsf@bsb.me.uk... > "Ansel" <tinker454@trytospammenowloser.com> writes: > >>>"christian.bau" <christian.bau@cbau.wanadoo.co.uk> wrote in message >>>news:2d5917c0-6c09-4c23-8672-d9aed340d1ea@l5g2000vbo.googlegroups.com... >>>On Jul 23, 8:32 am, "Ansel" <tinker...@trytospammenowloser.com> wrote: >>>> If C's unsigned integer types were designed so that their maximum value >>>> was >>>> the same as the absolute value of the same width signed integer type's >>>> minimum value, wouldn't that automagically elimintate a bunch of >>>> erroneous >>>> code and simplify programming in C? >>> >>>I'm curious to see an example, which you surely will post. >> >> Well the obvious one is that you could assign the negative of any >> unsigned >> int to an int without a care. It just seems conceptually simpler: less >> thinking about trivial details in the solution domain required. Maybe not >> overall though -- I'd have to think about it some more. > > I'm curious to see an example. > I was wondering. If you say "it ain't so", I will not "just believe you", because I actually want to *know* "it ain't so". I am seeking an analyis/discussion.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2012-07-25 01:53 +0100 |
| Message-ID | <0.455195f780fde9316baf.20120725015336BST.87obn4r78v.fsf@bsb.me.uk> |
| In reply to | #23696 |
"Ansel" <tinker454@trytospammenowloser.com> writes: > "Ben Bacarisse" <ben.usenet@bsb.me.uk> wrote in message > news:0.9437614bb6d82b2295aa.20120724112513BST.87vchdtq0m.fsf@bsb.me.uk... <snip> >>>>On Jul 23, 8:32 am, "Ansel" <tinker...@trytospammenowloser.com> wrote: >>>>> If C's unsigned integer types were designed so that their maximum value >>>>> was >>>>> the same as the absolute value of the same width signed integer type's >>>>> minimum value, wouldn't that automagically elimintate a bunch of >>>>> erroneous >>>>> code and simplify programming in C? <snip> >> I'm curious to see an example. > > I was wondering. If you say "it ain't so", I will not "just believe you", > because I actually want to *know* "it ain't so". I am seeking an > analyis/discussion. I thought that maybe you'd concluded that your suggestion would "simplify programming in C" because you'd worked through some examples, examples you could then share. If not, no worries. I just like to know what lies behind such posts because it helps me know how seriously to take them. -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | "Ansel" <tinker454@trytospammenowloser.com> |
|---|---|
| Date | 2012-07-24 21:43 -0600 |
| Message-ID | <junq3q$6g4$1@speranza.aioe.org> |
| In reply to | #23701 |
"Ben Bacarisse" <ben.usenet@bsb.me.uk> wrote in message news:0.455195f780fde9316baf.20120725015336BST.87obn4r78v.fsf@bsb.me.uk... > "Ansel" <tinker454@trytospammenowloser.com> writes: > >> "Ben Bacarisse" <ben.usenet@bsb.me.uk> wrote in message >> news:0.9437614bb6d82b2295aa.20120724112513BST.87vchdtq0m.fsf@bsb.me.uk... > <snip> >>>>>On Jul 23, 8:32 am, "Ansel" <tinker...@trytospammenowloser.com> wrote: >>>>>> If C's unsigned integer types were designed so that their maximum >>>>>> value >>>>>> was >>>>>> the same as the absolute value of the same width signed integer >>>>>> type's >>>>>> minimum value, wouldn't that automagically elimintate a bunch of >>>>>> erroneous >>>>>> code and simplify programming in C? > <snip> >>> I'm curious to see an example. >> >> I was wondering. If you say "it ain't so", I will not "just believe you", >> because I actually want to *know* "it ain't so". I am seeking an >> analyis/discussion. > > I thought that maybe you'd concluded that your suggestion would > "simplify programming in C" because you'd worked through some examples, > examples you could then share. If not, no worries. I just like to know > what lies behind such posts because it helps me know how seriously to > take them. > Oh, no -- I was just "throwing it out there" for the gurus, so as to not waste anymore time on it than necessary. It was more like, "hey, did anyone ever/even consider this?", because I assert that just having the hardware there could have block some trains of thought on the possibilities. I really don't know, so I "threw it out there". I'm really not the one to the potential use cases, and it's probably a team-thing anyway -- a la, this newsgroup (!). So far, we *know* full-range unsigneds are "very-nice-to-haves" (for character types and such), but java seems to do alright without them. In the cases where someone wants a full-range unsigned, like character types, are those kinds of things always non-arithmetic types? If so, maybe then the "half-range" arithmetic unsigned integer idea becomes plausible. Umm... I seem to be moving toward nixing the unsigned arithmetic integer types altogether, like java did, huh!
[toc] | [prev] | [next] | [standalone]
| From | "christian.bau" <christian.bau@cbau.wanadoo.co.uk> |
|---|---|
| Date | 2012-07-24 16:29 -0700 |
| Message-ID | <31ad2cd9-c1b9-4b92-b7bd-5ff84b03fa0a@x21g2000vbc.googlegroups.com> |
| In reply to | #23652 |
On Jul 24, 7:19 am, "Ansel" <tinker...@trytospammenowloser.com> wrote:
> >"christian.bau" <christian....@cbau.wanadoo.co.uk> wrote in message
> >I'm curious to see an example, which you surely will post.
>
> Well the obvious one is that you could assign the negative of any unsigned
> int to an int without a care.
Wow. What a big advantage.
Now what about assigning the positive value of any unsigned int to an
int? Because that doesn't work.
But actually, you f***ed it up completely.
Operations with unsigned int are performed modulo (UINT_MAX + 1).
If you have an unsigned int
unsigned int u = 1;
then the negative (-u) or -1u is _always_ UINT_MAX, which is equal to
the numerical value of -INT_MIN which is usually one greater than
INT_MAX. Surprise, surprise.
[toc] | [prev] | [next] | [standalone]
| From | "Ansel" <tinker454@trytospammenowloser.com> |
|---|---|
| Date | 2012-07-24 21:53 -0600 |
| Message-ID | <junqmr$7mk$1@speranza.aioe.org> |
| In reply to | #23698 |
"christian.bau" <christian.bau@cbau.wanadoo.co.uk> wrote in message news:31ad2cd9-c1b9-4b92-b7bd-5ff84b03fa0a@x21g2000vbc.googlegroups.com... On Jul 24, 7:19 am, "Ansel" <tinker...@trytospammenowloser.com> wrote: > > >"christian.bau" <christian....@cbau.wanadoo.co.uk> wrote in message > > >I'm curious to see an example, which you surely will post. > > > > Well the obvious one is that you could assign the negative of any > > unsigned > > int to an int without a care. Talking-back to myself: But you shouldn't be doing that anyway probably. > > Wow. What a big advantage. It seems to be a "hack-thing" (in a bad way) to be doing anyway. > Now what about assigning the positive value of any unsigned int to an > int? Because that doesn't work. Why wouldn't it? > > But actually, you f***ed it up completely. > Operations with unsigned int are performed modulo (UINT_MAX + 1). That is *one* type of integer, yes. Maybe "my" idea cannot be evaluated or had in isolation, but rather must be analyzed in the context of type system as a whole. I have a feeling that the whole discussion is about to become moot -- in favor of nixing arithmetic unsigneds altogether. > > If you have an unsigned int > > unsigned int u = 1; > > then the negative (-u) or -1u is _always_ UINT_MAX, which is equal to > the numerical value of -INT_MIN which is usually one greater than > INT_MAX. Surprise, surprise.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2012-07-24 23:24 -0700 |
| Message-ID | <lnhasw8ik4.fsf@nuthaus.mib.org> |
| In reply to | #23705 |
"Ansel" <tinker454@trytospammenowloser.com> writes:
> "christian.bau" <christian.bau@cbau.wanadoo.co.uk> wrote in message
> news:31ad2cd9-c1b9-4b92-b7bd-5ff84b03fa0a@x21g2000vbc.googlegroups.com...
> On Jul 24, 7:19 am, "Ansel" <tinker...@trytospammenowloser.com> wrote:
>> > >"christian.bau" <christian....@cbau.wanadoo.co.uk> wrote in message
>> > >I'm curious to see an example, which you surely will post.
>> >
>> > Well the obvious one is that you could assign the negative of any
>> > unsigned
>> > int to an int without a care.
>
> Talking-back to myself: But you shouldn't be doing that anyway probably.
>>
>> Wow. What a big advantage.
>
> It seems to be a "hack-thing" (in a bad way) to be doing anyway.
>
>> Now what about assigning the positive value of any unsigned int to an
>> int? Because that doesn't work.
>
> Why wouldn't it?
Under your proposal, you'd might have signed int with a range of
-32768 to +32767, and unsigned int with a range of 0 to +32768.
You wouldn't be able to assign an unsigned int value of +32768
to a signed int object without changing the mathematical value.
(Adjust values for 32-bit ints.)
I'm skeptical that your proposal, or anything similar to it, would
be an improvement over what we have now.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | "Ansel" <tinker454@trytospammenowloser.com> |
|---|---|
| Date | 2012-07-25 01:12 -0600 |
| Message-ID | <juo6nq$vbq$1@speranza.aioe.org> |
| In reply to | #23709 |
"Keith Thompson" <kst-u@mib.org> wrote in message news:lnhasw8ik4.fsf@nuthaus.mib.org... > "Ansel" <tinker454@trytospammenowloser.com> writes: >> "christian.bau" <christian.bau@cbau.wanadoo.co.uk> wrote in message >> news:31ad2cd9-c1b9-4b92-b7bd-5ff84b03fa0a@x21g2000vbc.googlegroups.com... >> On Jul 24, 7:19 am, "Ansel" <tinker...@trytospammenowloser.com> wrote: >>> > >"christian.bau" <christian....@cbau.wanadoo.co.uk> wrote in message >>> > >I'm curious to see an example, which you surely will post. >>> > >>> > Well the obvious one is that you could assign the negative of any >>> > unsigned >>> > int to an int without a care. >> >> Talking-back to myself: But you shouldn't be doing that anyway probably. >>> >>> Wow. What a big advantage. >> >> It seems to be a "hack-thing" (in a bad way) to be doing anyway. >> >>> Now what about assigning the positive value of any unsigned int to an >>> int? Because that doesn't work. >> >> Why wouldn't it? > > Under your proposal, you'd might have signed int with a range of > -32768 to +32767, and unsigned int with a range of 0 to +32768. -32767 to +32767 > You wouldn't be able to assign an unsigned int value of +32768 > to a signed int object without changing the mathematical value. > (Adjust values for 32-bit ints.) > > I'm skeptical that your proposal, or anything similar to it, would > be an improvement over what we have now. >
[toc] | [prev] | [next] | [standalone]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Date | 2012-07-23 10:37 +0100 |
| Message-ID | <pan.2012.07.23.09.37.54.704000@nowhere.com> |
| In reply to | #23604 |
On Mon, 23 Jul 2012 01:32:59 -0600, Ansel wrote: > If C's unsigned integer types were designed so that their maximum value > was the same as the absolute value of the same width signed integer type's > minimum value, wouldn't that automagically elimintate a bunch of erroneous > code Maybe, although it would probably introduce at least as much erroneous code as it eliminated. > and simplify programming in C? No.
[toc] | [prev] | [next] | [standalone]
| From | Andre <lodwig@pathme.de> |
|---|---|
| Date | 2012-07-23 11:46 +0200 |
| Message-ID | <juj6i6$dfe$1@speranza.aioe.org> |
| In reply to | #23606 |
On 23.07.2012 11:37, Nobody wrote: > On Mon, 23 Jul 2012 01:32:59 -0600, Ansel wrote: > >> If C's unsigned integer types were designed so that their maximum value >> was the same as the absolute value of the same width signed integer type's >> minimum value, wouldn't that automagically elimintate a bunch of erroneous >> code > > Maybe, although it would probably introduce at least as much erroneous > code as it eliminated. At least in 2038... http://en.wikipedia.org/wiki/Year_2038_problem > >> and simplify programming in C? > > No. >
[toc] | [prev] | [next] | [standalone]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Date | 2012-07-23 11:33 +0100 |
| Message-ID | <juj9b4$25k$1@dont-email.me> |
| In reply to | #23604 |
"Ansel" <tinker454@trytospammenowloser.com> wrote in message news:juiuqb$rau$1@speranza.aioe.org... > If C's unsigned integer types were designed so that their maximum value > was > the same as the absolute value of the same width signed integer type's > minimum value, wouldn't that automagically elimintate a bunch of erroneous > code and simplify programming in C? Assuming an 8-bit int type, the normal signed/unsigned ranges might be -128 to +127, and 0 to 255. You're suggesting the unsigned range ought to be 0 to 128? That sounds very difficult to implement; what happens if you have 128 unsigned, and add one? Every arithmetic operation would need extra code to detect the overflow, and convert numbers such as +129 to 0. With a few special cases such as 128+128. You would also be wasting most of the top bit (only used when representing 128). Then there are the illegal values 129 to 255, which uninitialised data is likely to have. And then, with the char type, you would also be limited to a maximum of +128, cutting out most of the extra ANSI characters. In fact, every piece of coding relying on a byte having a range of 0 to 255 (as used in much of the internet for example), would need rewriting to use a wider int to cover that range. And what happens when, for example, reading a file of 8-bit characters which have been created when the range allowed +130 to 255 (eg. much of the world's stored data); you would now have a block of illegal values instead. So I can see a few snags with the idea. -- Bartc
[toc] | [prev] | [next] | [standalone]
| From | "Ansel" <tinker454@trytospammenowloser.com> |
|---|---|
| Date | 2012-07-23 23:48 -0600 |
| Message-ID | <juld2l$gsb$1@speranza.aioe.org> |
| In reply to | #23608 |
"BartC" <bc@freeuk.com> wrote in message news:juj9b4$25k$1@dont-email.me... > > > "Ansel" <tinker454@trytospammenowloser.com> wrote in message > news:juiuqb$rau$1@speranza.aioe.org... >> If C's unsigned integer types were designed so that their maximum value >> was >> the same as the absolute value of the same width signed integer type's >> minimum value, wouldn't that automagically elimintate a bunch of >> erroneous >> code and simplify programming in C? > > Assuming an 8-bit int type, I was actually thinking about every width *except* 8-bits when I posted. > the normal signed/unsigned ranges might be -128 > to +127, and 0 to 255. > > You're suggesting the unsigned range ought to be 0 to 128? That would be the scene with *your* 8-bit int type, yes. And I wasn't "suggesting", I was wondering. > > That sounds very difficult to implement; It's quite simple actually. > what happens if you have 128 > unsigned, and add one? That depends on the type of integer: saturating or modular or except-on-overflow. Note that my OP was basically referring to a "ranged", or "range-restricted", integer. > Every arithmetic operation would need extra code Indeed it would, but it is minor and in most cases not detriental and it wouldn't preclude having another integer type called "fast-and-less-safe integer" or something. I.e., should the concept pan out to be worthwhile. And again, I wasn't *suggesting* with my OP, rather just throwing a thought on the table for discussion. >detect the overflow, and convert numbers such as +129 to 0. With a few > special cases such as 128+128. > > You would also be wasting most of the top bit (only used when representing > 128). Then there are the illegal values 129 to 255, which uninitialised > data > is likely to have. > > And then, with the char type, you would also be limited to a maximum of > +128, cutting out most of the extra ANSI characters. > > In fact, every piece of coding relying on a byte having a range of 0 to > 255 > (as used in much of the internet for example), would need rewriting to use > a wider int to cover that range. Noted above. For 'char' and 'byte' types allow the full unsigned range. Probably, for all unsigned ints that are not arithmetic types. > > And what happens when, for example, reading a file of 8-bit characters > which > have been created when the range allowed +130 to 255 (eg. much of the > world's stored data); you would now have a block of illegal values > instead. 1. My scenario was if it had been that way from the start, would we be better off. 2. Non-arithmetic types could use the full range that 8-bits allow. > > So I can see a few snags with the idea. > Name one. ;)
[toc] | [prev] | [next] | [standalone]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Date | 2012-07-24 10:43 +0100 |
| Message-ID | <julqqp$5qg$1@dont-email.me> |
| In reply to | #23651 |
"Ansel" <tinker454@trytospammenowloser.com> wrote in message news:juld2l$gsb$1@speranza.aioe.org... > > "BartC" <bc@freeuk.com> wrote in message > news:juj9b4$25k$1@dont-email.me... >> >> >> "Ansel" <tinker454@trytospammenowloser.com> wrote in message >> news:juiuqb$rau$1@speranza.aioe.org... >>> If C's unsigned integer types were designed so that their maximum value >>> was >>> the same as the absolute value of the same width signed integer type's >>> minimum value, wouldn't that automagically elimintate a bunch of >>> erroneous >>> code and simplify programming in C? >> >> Assuming an 8-bit int type, > > I was actually thinking about every width *except* 8-bits when I posted. I chose 8-bits to simplify the examples. But, what's special about 8-bits that they ought to be allowed a conventional unsigned range; perhaps it's easier to think of examples where things would stop working..? >> the normal signed/unsigned ranges might be -128 >> to +127, and 0 to 255. >> >> You're suggesting the unsigned range ought to be 0 to 128? > > That would be the scene with *your* 8-bit int type, yes. And I wasn't > "suggesting", I was wondering. OK, choosing a 16-bit type, you were wondering whether the unsigned range ought to be 0 to 32768 instead of 0 to 65535. I think it would be simpler to restrict it to 0 to 32767, ie just the positive values of a signed int type. (That means you can't represent -(-32768), but you can't do that as a signed value anyway.) Then you just have to mask the top bit in every operation. But then, that would be little different from not having unsigned at all, and and only using the top half of each signed int range. > >> >> That sounds very difficult to implement; > > It's quite simple actually. > >> what happens if you have 128 >> unsigned, and add one? > > That depends on the type of integer: saturating or modular or > except-on-overflow. Note that my OP was basically referring to a "ranged", > or "range-restricted", integer. There is some merit to ranged-integer types, but the range would need to be enforced (not popular in C) and the type system becomes massively more complicated (what's the result of adding a 100..200 type to a 150..250 type?). Also, a range is usually a subset of the allowed int range; yours would be a superset! Because the top value will be one more than the normal range of a signed int. It *might* work as a range of the full unsigned int type, but that requires the normal, unconstrained unsigned type to be still available. Otherwise there are just two many problems, if any arbitrary value of 16, 32 or 64 bits you might encounter, can only ever be represented as signed, so will be negative half the time. You can't even convert -1 to unsigned, and back again, as C can now; you can't represent -1 as unsigned at all. -- Bartc
[toc] | [prev] | [next] | [standalone]
| From | Malcolm McLean <malcolm.mclean5@btinternet.com> |
|---|---|
| Date | 2012-07-24 02:58 -0700 |
| Message-ID | <ca08c533-bbd7-45b4-b9c4-391770c358cd@googlegroups.com> |
| In reply to | #23661 |
בתאריך יום שלישי, 24 ביולי 2012 10:43:52 UTC+1, מאת Bart: > > I chose 8-bits to simplify the examples. But, what's special about 8-bits > that they ought to be allowed a conventional unsigned range; perhaps it's > easier to think of examples where things would stop working..? > You commonly use 8 bit unsigneds to pull out bit strings from an input channel. Also, as ranges get smaller, you're more likely to use the upper half of the range. Plenty of people use the range 0-255 to represent a colour channel intensity value, or to index into a table of glyphs. However there's not going to be much difference visually between 32 thousand or 64 thousand greyscale values if you go to 16 bit colour channels. Similarly it's unlikely that you have a need for between 32,000 and 64,000 glyphs.
[toc] | [prev] | [next] | [standalone]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Date | 2012-07-24 12:04 +0100 |
| Message-ID | <julvgs$ums$1@dont-email.me> |
| In reply to | #23662 |
"Malcolm McLean" <malcolm.mclean5@btinternet.com> wrote in message news:ca08c533-bbd7-45b4-b9c4-391770c358cd@googlegroups.com... > בתאריך יום שלישי, 24 ביולי 2012 10:43:52 UTC+1, מאת Bart: >> >> But, what's special about 8-bits >> that they ought to be allowed a conventional unsigned range > Also, as ranges get smaller, you're more likely to use the upper half of > the range. >Similarly it's unlikely that you have a need for between 32,000 and 64,000 >glyphs. Unicode seems to think it needs that many (more in fact). But, any time you want to treat two 8-bit bytes as a single 16-bit unit, or four as 32-bit, it would be crazy not to have a suitable type to represent that, without having to treat half the possible values as negative numbers. How would you right-shift the result for example? -- Bartc
[toc] | [prev] | [next] | [standalone]
| From | Malcolm McLean <malcolm.mclean5@btinternet.com> |
|---|---|
| Date | 2012-07-24 05:32 -0700 |
| Message-ID | <d5cf3732-97c3-4dc9-8b6c-505559a28bdb@googlegroups.com> |
| In reply to | #23665 |
בתאריך יום שלישי, 24 ביולי 2012 12:04:42 UTC+1, מאת Bart: > Malcolm McLean;malcolm.mclean5@btinternet.com> wrote in message > > Unicode seems to think it needs that many (more in fact). > Unicode has 110,000 characters at last count. So 16 bit unsigneds aren't really helpful. You might want a subset of Unicode that has more than 256 characters, but the number of sitations where you want a subset with more than 32,000, less than 64,000, and you don't want to just go to 32 bits in case of future extensions is limited.
[toc] | [prev] | [next] | [standalone]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Date | 2012-07-24 14:20 +0100 |
| Message-ID | <jum7f0$crk$1@dont-email.me> |
| In reply to | #23673 |
"Malcolm McLean" <malcolm.mclean5@btinternet.com> wrote in message news:d5cf3732-97c3-4dc9-8b6c-505559a28bdb@googlegroups.com... > בתאריך יום שלישי, 24 ביולי 2012 12:04:42 UTC+1, מאת Bart: >> Malcolm McLean;malcolm.mclean5@btinternet.com> wrote in message >> >> Unicode seems to think it needs that many (more in fact). >> > Unicode has 110,000 characters at last count. So 16 bit unsigneds aren't > really helpful. You might want a subset of Unicode that has more than 256 > characters, but the number of sitations where you want a subset with more > than 32,000, less than 64,000, and you don't want to just go to 32 bits in > case of future extensions is limited. What you're saying is that you could live with a set of numeric types where these ranges: 16-bit: 32768 to 65535 (32769 to 65535 in OP's scheme) 32-bit: 2 billion to 4 billion approx 64-bit: 9 to 18 trillion approx simply don't exist? At least, without representing them with a bit-pattern normally used for negative values, or having to use the next wider type. That seems too restrictive at this level of language, where you don't have recourse to anything lower level without going into machine code. -- Bartc
[toc] | [prev] | [next] | [standalone]
Page 1 of 6 [1] 2 3 4 5 6 Next page →
Back to top | Article view | comp.lang.c
csiph-web