Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #6084
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | David Brown <david.brown@hesbynett.no> |
| Newsgroups | comp.programming |
| Subject | Re: Here is why C++ and C are bad... |
| Date | Wed, 30 Dec 2015 18:19:29 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 55 |
| Message-ID | <n613i4$jca$3@dont-email.me> (permalink) |
| References | <n5kdn4$cji$1@dont-email.me> <n5uqdd$gin$1@dont-email.me> <n5v0di$7i3$1@dont-email.me> <n5v0p5$8s3$1@dont-email.me> <n6063m$ccb$1@dont-email.me> <n60m14$lf$1@dont-email.me> <87h9j06ip1.fsf@bsb.me.uk> <n610v9$afu$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Wed, 30 Dec 2015 17:16:52 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="dc28719e2ffeeb5899be5f5057009353"; logging-data="19850"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18dVNwGBKwS54JHTQ+NMUavrJXMa1pgkEs=" |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <n610v9$afu$1@dont-email.me> |
| Cancel-Lock | sha1:xXpcZuq24klrzY6t474Derry/MM= |
| Xref | csiph.com comp.programming:6084 |
Show key headers only | View raw
On 30/12/15 17:35, Richard Heathfield wrote: > On 30/12/15 15:48, Ben Bacarisse wrote: > > <snip> > >> Since this is comp.programming, you should perhaps have said that mixing >> signed and unsigned expressions _in C_ is often a bad sign. It may be >> in other languages too, but there are others in which it is both common >> and harmless. > > Fair comment. So perhaps we could start by looking at how some other > languages deal with unsigned integer types (or indeed whether they > support them at all). I should say at the outset that the information I > present below is unsatisfactorily sparse. > > Ada supports signed and unsigned integer types. I couldn't find any > rules on how mixed-sign arithmetic is done (but that doesn't mean there > aren't any). > > BASIC - tricky one. ISO/IEC 10279 defines the language, but I couldn't > find a freely available draft. > > COBOL (according to a rather strangely-formatted draft ISO Standard from > 2005) seems to support unsigned char, short, long, and even double. It > isn't clear (from a quick scan) how COBOL deals with mixed-sign arithmetic. > > D's rules are similar to C's. Particularly, if the two types are of the > same size, then the signed type is converted to unsigned. > > Eiffel supports unsigned integer types, but I found nothing in ECMA-367 > to show how they interact with signed types. > > Fortran's draft standard (n3501) is rather odd. In Note 15.9 we find > that "...Fortran does not provide direct support for unsigned kinds of > integers", and yet in 4.4.1 Integer Type the text reads "The value of a > signed integer zero is the same as the value of an unsigned integer > zero", which suggests that there is /some/ kind of support for unsigned > integers. > > Go supports unsigned integer types, but a brief perusal of the spec > didn't turn up any rules for mixed-sign arithmetic. > > I ran out of time to extend this alphabetical list any further, but one > of the first languages I thought of was PHP. I found it surprising that > PHP doesn't appear to support an unsigned integer type (something that > it has never before occurred to me to check, which suggests to me that I > don't use PHP quite as often as I thought I did). > You didn't get as far as Python, I take it. In Python, the integer types just get as big as you need (until you run out of time or memory). So to a large extent you can assume your integers really are mathematical integers, and add them as much as you want. (So "unsigned" integers don't really exist.)
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-29 20:31 +0000
Re: Here is why C++ and C are bad... Kaz Kylheku <kaz@kylheku.com> - 2015-12-29 21:20 +0000
Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-29 23:13 +0100
Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-29 22:19 +0000
Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 09:56 +0100
Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 13:28 +0000
Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 14:55 +0100
Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 16:32 +0000
Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 18:17 +0100
Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 20:01 +0000
Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 15:48 +0000
Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 16:35 +0000
Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 18:19 +0100
Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 17:39 +0000
Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 20:26 +0000
Re: Here is why C++ and C are bad... "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2015-12-30 18:32 +0100
Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 19:55 +0000
Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 20:15 +0000
Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 22:00 +0000
Re: Here is why C++ and C are bad... Ian Collins <ian-news@hotmail.com> - 2015-12-31 10:16 +1300
csiph-web