--- Begin Message ---
- To: "Debian Bug Tracking System" <submit@bugs.debian.org>
- Subject: why: caduceus: the abs example is in fact wrong
- From: Jiří Paleček <jpalecek@web.de>
- Date: Fri, 22 Jun 2007 16:38:08 +0200
- Message-id: <op.tubuxmk9u2flwt@localhost>
Package: why
Version: 2.03.dfsg-1
Severity: normal
Hello,
the "abs" example, which is bundled with caduceus, is not really correct.
What's the problem:
/* @ensures \result > 0 */
int abs(int x) { return x<0 ? -x : x; }
This number work for all integers, except for one. In the base-2
complement,
there are two numbers which staisfy x==-x. One is 0, and the other is
0x80000000 hex (on 32 bit architecture), which is negative. therefore,
abs(this number) is negative.
Regards
Jiri Palecek
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.20.3-rt8 (PREEMPT)
Locale: LANG=cs_CZ, LC_CTYPE=cs_CZ (charmap=ISO-8859-2) (ignored: LC_ALL
set to cs_CZ)
Shell: /bin/sh linked to /bin/dash
Versions of packages why depends on:
ii libatk1.0-0 1.18.0-2 The ATK accessibility toolkit
ii libc6 2.5-11 GNU C Library: Shared
libraries
ii libcairo2 1.4.6-1.1 The Cairo 2D vector graphics
libra
ii libfontconfig1 2.4.2-1.2 generic font configuration
library
ii libglib2.0-0 2.12.12-1 The GLib library of C routines
ii libgtk2.0-0 2.10.13-1 The GTK+ graphical user
interface
ii libpango1.0-0 1.16.4-1 Layout and rendering of
internatio
ii libx11-6 2:1.0.3-7 X11 client-side library
ii libxcursor1 1:1.1.8-2 X cursor management library
ii libxext6 1:1.0.3-2 X11 miscellaneous extension
librar
ii libxfixes3 1:4.0.3-2 X11 miscellaneous 'fixes'
extensio
ii libxi6 1:1.0.1-4 X11 Input extension library
ii libxinerama1 1:1.0.2-1 X11 Xinerama extension library
ii libxrandr2 2:1.2.1-1 X11 RandR extension library
ii libxrender1 1:0.9.2-1 X Rendering Extension client
libra
why recommends no packages.
-- no debconf information
--- End Message ---
--- Begin Message ---
- To: Jiří Paleček <jpalecek@web.de>, 430126-done@bugs.debian.org
- Subject: Re: Bug#430126: why: caduceus: the abs example is in fact wrong
- From: Mehdi Dogguy <mehdi@dogguy.org>
- Date: Mon, 16 Jan 2012 19:12:36 +0100
- Message-id: <20120116181236.GA11216@dogguy.org>
- In-reply-to: <op.tubuxmk9u2flwt@localhost>
- References: <op.tubuxmk9u2flwt@localhost>
Version: 2.04.dfsg-1
Jiří Paleček <jpalecek@web.de> wrote:
> Package: why
> Version: 2.03.dfsg-1
> Severity: normal
>
> Hello,
>
> the "abs" example, which is bundled with caduceus, is not really correct.
>
> What's the problem:
>
> /* @ensures \result > 0 */
> int abs(int x) { return x<0 ? -x : x; }
>
> This number work for all integers, except for one. In the base-2
> complement,
> there are two numbers which staisfy x==-x. One is 0, and the other is
> 0x80000000 hex (on 32 bit architecture), which is negative. therefore,
> abs(this number) is negative.
>
I think that this is fixed since quite some time now. Closing...
Regards,
--
Mehdi Dogguy
--- End Message ---