Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "Osmium" <r124c4u102@comcast.net> |
| Newsgroups | comp.lang.c |
| Subject | Re: unsigned int |
| Date | Sun, 31 Jul 2016 12:40:37 -0500 |
| Lines | 40 |
| Message-ID | <e06rglFmcd5U1@mid.individual.net> (permalink) |
| References | <unsigned-20160731163521@ram.dialup.fu-berlin.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; format=flowed; charset="iso-8859-1"; reply-type=original |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net e9fJWyzQQV97c9Cte1/TewEbbOxlCq5Lc1ZYbCliVU/NOQrQFC |
| Cancel-Lock | sha1:dcKHcBFa4kzowyDOcQnds0Tg/vs= |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| X-Newsreader | Microsoft Outlook Express 6.00.2900.2180 |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.2900.2180 |
| Xref | csiph.com comp.lang.c:91404 |
Show key headers only | View raw
"Stefan Ram" wrote:
> I am now trying to write a new lesson for my German-language
> C course. This time about »unsigned« (say, »unsigned int«,
> for a start).
>
> So, what are the crucial facts the readers need to know?
>
> Some things that come to my mind right now ("brainstorming"):
>
> - unsigned has defined semantics on overflow and underflow
>
> - comparisons like »<« can give unexpected results (I need
> to figure out the possible cases where this can happen,
> maybe you have such a case handy?)
>
> - there are suffixes for numerals to mark them as usigned,
> like »u«
>
> - But sometimes, the type of a numeral that is not marked
> with a suffix but is too large to be an int is »unsigned«?
> (But this has changed between several standards? Or was
> this in C++?)
>
> - A special conversion specification has to be used for
> printf (scanf will only be treated later in the course)
>
> - there are the usual macros in <limits.h> for »unsigned int«.
>
> - I don't actually know the semantics for conversions
> between signed and unsigned, but I think a can look them
> up in the standard.
>
> - what did I miss? (Especially with regard to common errors
> commited when using »unsigned«.)
A novice would naturally think that char was signed by default, the same as
an int. It is not, the default is chosen by the compiler writer. Among
other things, this has ramifications in bit shifting within characters,.
Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread
Re: unsigned int "Osmium" <r124c4u102@comcast.net> - 2016-07-31 12:40 -0500
Re: unsigned int David Brown <david.brown@hesbynett.no> - 2016-08-01 11:01 +0200
Re: unsigned int James Kuyper <jameskuyper@verizon.net> - 2016-08-01 10:15 -0400
Re: unsigned int Les Cargill <lcargill99@comcast.com> - 2016-08-01 09:59 -0500
Re: unsigned int David Brown <david.brown@hesbynett.no> - 2016-08-01 17:21 +0200
Re: unsigned int Keith Thompson <kst-u@mib.org> - 2016-08-01 09:55 -0700
Re: unsigned int David Brown <david.brown@hesbynett.no> - 2016-08-01 22:42 +0200
Re: unsigned int supercat@casperkitty.com - 2016-08-01 14:18 -0700
Re: unsigned int Les Cargill <lcargill99@comcast.com> - 2016-08-01 13:11 -0500
Re: unsigned int Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-01 19:46 +0100
Re: unsigned int Les Cargill <lcargill99@comcast.com> - 2016-08-01 18:20 -0500
Re: unsigned int David Brown <david.brown@hesbynett.no> - 2016-08-02 10:18 +0200
Re: unsigned int Les Cargill <lcargill99@comcast.com> - 2016-08-02 09:35 -0500
Re: unsigned int Keith Thompson <kst-u@mib.org> - 2016-08-02 08:00 -0700
Re: unsigned int Les Cargill <lcargill99@comcast.com> - 2016-08-02 11:12 -0500
Re: unsigned int David Brown <david.brown@hesbynett.no> - 2016-08-02 17:11 +0200
Re: unsigned int Les Cargill <lcargill99@comcast.com> - 2016-08-02 11:55 -0500
Re: unsigned int supercat@casperkitty.com - 2016-08-02 10:16 -0700
Re: unsigned int David Brown <david.brown@hesbynett.no> - 2016-08-03 14:02 +0200
Re: unsigned int Keith Thompson <kst-u@mib.org> - 2016-08-03 08:58 -0700
Re: unsigned int James Kuyper <jameskuyper@verizon.net> - 2016-08-02 13:57 -0400
Re: unsigned int Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-08-02 19:30 +0100
Re: unsigned int Keith Thompson <kst-u@mib.org> - 2016-08-02 11:38 -0700
Re: unsigned int David Brown <david.brown@hesbynett.no> - 2016-08-03 14:12 +0200
Re: unsigned int David Brown <david.brown@hesbynett.no> - 2016-08-03 13:45 +0200
Re: unsigned int Keith Thompson <kst-u@mib.org> - 2016-08-01 12:02 -0700
Re: unsigned int David Brown <david.brown@hesbynett.no> - 2016-08-01 23:01 +0200
csiph-web