πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #3675

Re: binary string als int afdrukken in C

#3675
From: Arnold Hendriks
Date: Sun, 30 Nov 2003 13:17
18 lines
1878 bytes
"Gunter Schelfhout" <nospam@please.com> wrote in message
news:WYhyb.52209$yO2.1718407@phobos.telenet-ops.be...

> Een eigenaardigheidje:
> ...
> printf("%i\n", strtol(bin, NULL, 2));
> ...
> geeft altijd hetzelfde resultaat, ongeacht de string van 32 bits.
> Een printout van bin geeft bv:
> 11011000000011001100100000100000

32 bits is een overflow op veel machines, en dan:

       unless the origοΏ½-
       inal (non-negated) value would  overflow;  in  the  latter
       case,  strtoul()  returns  ULONG_MAX  and  sets the global
       variable errno to ERANGE.  Precisely the  same  holds  for
       strtoull() (with ULLONG_MAX instead of ULONG_MAX).
Technical Details
Message-ID: <bqcqlc$jhu$1@netlx020.civ.utwente.nl>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!surfnet.nl!news.utwente.nl!not-for-mail
References: <td1yb.50435$xX1.1629315@phobos.telenet-ops.be> <slrnbshhuh.3sc.staf_nospam_@localhost.staflaptop> <bqaho7$tou$1@netlx020.civ.utwente.nl> <kbayb.51726$RJ2.1708097@phobos.telenet-ops.be> <WYhyb.52209$yO2.1718407@phobos.telenet-ops.be>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: fcea4,12763d3d6faef1bf
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-11-30 05:17:34 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!surfnet.nl!news.utwente.nl!not-for-mail
From: "Arnold Hendriks" <a.hendriks@b-lex.nl>
Newsgroups: be.comp.programming
Subject: Re: binary string als int afdrukken in C
Date: Sun, 30 Nov 2003 14:17:31 +0100
Organization: University of Twente, Enschede, The Netherlands
Lines: 20
Message-ID: <bqcqlc$jhu$1@netlx020.civ.utwente.nl>
References: <td1yb.50435$xX1.1629315@phobos.telenet-ops.be> <slrnbshhuh.3sc.staf_nospam_@localhost.staflaptop> <bqaho7$tou$1@netlx020.civ.utwente.nl> <kbayb.51726$RJ2.1708097@phobos.telenet-ops.be> <WYhyb.52209$yO2.1718407@phobos.telenet-ops.be>
NNTP-Posting-Host: jeltsin.student.utwente.nl
X-Trace: netlx020.civ.utwente.nl 1070198252 20030 130.89.163.169 (30 Nov 2003 13:17:32 GMT)
X-Complaints-To: abuse@utwente.nl
NNTP-Posting-Date: Sun, 30 Nov 2003 13:17:32 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165