Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

All the existing 2.0.x kernels are to buggy for 2.1.x to be the main goal. -- Alan Cox


devel / comp.lang.python / Re: Unexpected behaviour of math.floor, round and int functions (rounding)

SubjectAuthor
* Unexpected behaviour of math.floor, round and int functions (rounding)René Silva Valdés
`- Re: Unexpected behaviour of math.floor, round and int functions (rounding)Julio Di Egidio

1
Unexpected behaviour of math.floor, round and int functions (rounding)

<mailman.43.1637289034.19479.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16046&group=comp.lang.python#16046

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: rene.sil...@gmail.com (René Silva Valdés)
Newsgroups: comp.lang.python
Subject: Unexpected behaviour of math.floor, round and int functions (rounding)
Date: Thu, 18 Nov 2021 23:16:32 -0300
Lines: 31
Message-ID: <mailman.43.1637289034.19479.python-list@python.org>
References: <CAF_USHuJ0bV7X9hWiciKwBL6=1zFCHfrFbPeV6KuVRnvFbwvmA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de G8hxfvzQdsLZbBTZE9Lj2Qit5ap7SwGy2r/zYMUr0cOg==
Return-Path: <rene.silva.valdes@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=erw3kUtn;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: UNSURE 0.300
X-Spam-Level: **
X-Spam-Evidence: '*H*': 0.43; '*S*': 0.02; 'language,': 0.09;
'reference:': 0.09; 'helpful,': 0.16; 'to:addr:python-list': 0.20;
'issue': 0.21; 'returns': 0.22; 'anything': 0.25; 'examples':
0.25; 'seems': 0.26; 'function': 0.27; 'url:bugs': 0.28;
"doesn't": 0.32; 'message-id:@mail.gmail.com': 0.32;
'received:google.com': 0.34; 'following': 0.35;
'from:addr:gmail.com': 0.35; 'received:209.85': 0.37; '8bit%:14':
0.38; 'thanks': 0.38; 'received:209': 0.39; 'this,': 0.39; '(see':
0.40; 'double': 0.40; 'hello,': 0.40; 'skip:0 20': 0.61; 'skip:i
20': 0.62; 'from:charset:utf-8': 0.64; 'skip:k 10': 0.64; 'skip:r
20': 0.64; 'less': 0.65; 'operations': 0.68; 'further': 0.69;
'8bit%:6': 0.71; 'known': 0.84; 'implies': 0.84;
'received:209.85.161': 0.84; 'that:': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:from:date:message-id:subject:to;
bh=oljWKYAWzBClE0xsvsHdtHzuSWZwE6yAoD8Aa6Adu7k=;
b=erw3kUtnZTwzkz1XIOel1QdtvDFP7hU3RtS4Tpkchm8WUlIvo9HaB/tL3/8olltpyk
6RlwZAUORoGXXzi7A5aNLV5LKKte4EjE0+R9JdWVfJ2Qvb69DfjFX6as+GKmyEnJInGb
D/O07yWN7FXQXxGWlztDv73wCOSOTe5RTFYFR0Au3OjIudjTFlmu6Dd/F6ox2xLMIqHV
Xv6cqmSh6ndFCLXT/YWK1vfFELSaPjBDX2GusFMZisJGynrYsihAu58s63tTqLXOTG/1
7b6d7wrOO3SHI0XyM4L1x8411auEGzHhnMf02GvGaLjfDt8a+ZCFaomBVH+ZGoWdCS8V
3NPg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=oljWKYAWzBClE0xsvsHdtHzuSWZwE6yAoD8Aa6Adu7k=;
b=tfIvkBP79uaNI+XvhFNuvGzyqFs8/7oz/YYPwxKSEwLjnYQgIOE6YfGqUwisc8hEjV
tvE9CxH/+AeQRlcHL4RkoI93tXNz+5vf7Yn4qe6NQGdmomCgHmDvKRzpIrNDcDFEPo5c
MKAiNAtdsWkrHaQiI9OSj3gikE86j8cTW9CoLBZefHRUp7xSappalenAFbTmFOkww2wM
WUN3PXiSirVXfRiRR03QXZYddzRm7XYXkHsTdbi3MjBnwKI8H5rZic3WyBCTFDT4y2qD
XKjJWFIpKOlCfpNZBv7sscOxFmflOkxrUC60XA8XbKyP3huRHzpKVS+UunD4wkenKGag
Dslg==
X-Gm-Message-State: AOAM533lcfysYDeLZjT+UUWhflwxebIEGEF583oKddY1W2cvn0IbgWIK
+Wy4soxdr49mJ1Lv5HhfLvh1nuuADTB/gwb2DDz6rD3bB1U=
X-Google-Smtp-Source: ABdhPJxs0Uw41mrrG+g0By2pkswaZ4C90S6av7crdgZ5tdxkKakHG6nBpIZIJfsNsyOkHrNmW0vQVxzPGTmI37hx4Lo=
X-Received: by 2002:a4a:dc88:: with SMTP id g8mr15784715oou.3.1637288203269;
Thu, 18 Nov 2021 18:16:43 -0800 (PST)
X-Mailman-Approved-At: Thu, 18 Nov 2021 21:30:32 -0500
X-Content-Filtered-By: Mailman/MimeDel 2.1.37
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.37
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAF_USHuJ0bV7X9hWiciKwBL6=1zFCHfrFbPeV6KuVRnvFbwvmA@mail.gmail.com>
 by: René Silva Valdés - Fri, 19 Nov 2021 02:16 UTC

Hello, I would like to report the following issue:

Working with floats i noticed that:

int(23.99999999999999/12) returns 1, and
int(23.999999999999999/12) returns 2

This implies that int() function is rounding, which doesn't appear to be
expected (documentation doesn't say anything about it). Looking further i
noticed that

0.5+0.49999999999999994 returns 1. This seems to be related to double
numbers' operations in C language, where 0.49999999999999994 is the
greatest floating-point value less than 0.5. Counting on this several
examples can be deduced, like:

round(0+0.49999999999999994) returns 0, and
round(1+0.49999999999999994) returns 2

This seems to be a known issue in Java (see reference)

Reference:

https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6430675

I hope this information is helpful, thanks in advance for reading this,

Kind regards,

René

Re: Unexpected behaviour of math.floor, round and int functions (rounding)

<04d04b9d-ea4f-490a-ae0d-a1194a01f9b1n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16051&group=comp.lang.python#16051

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:a6d0:: with SMTP id p199mr25706045qke.505.1637305528327;
Thu, 18 Nov 2021 23:05:28 -0800 (PST)
X-Received: by 2002:ac8:183:: with SMTP id x3mr3720411qtf.279.1637305527873;
Thu, 18 Nov 2021 23:05:27 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Thu, 18 Nov 2021 23:05:27 -0800 (PST)
In-Reply-To: <mailman.43.1637289034.19479.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.98.212; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.98.212
References: <CAF_USHuJ0bV7X9hWiciKwBL6=1zFCHfrFbPeV6KuVRnvFbwvmA@mail.gmail.com>
<mailman.43.1637289034.19479.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <04d04b9d-ea4f-490a-ae0d-a1194a01f9b1n@googlegroups.com>
Subject: Re: Unexpected behaviour of math.floor, round and int functions (rounding)
From: jul...@diegidio.name (Julio Di Egidio)
Injection-Date: Fri, 19 Nov 2021 07:05:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 14
 by: Julio Di Egidio - Fri, 19 Nov 2021 07:05 UTC

On Friday, 19 November 2021 at 03:30:51 UTC+1, René Silva Valdés wrote:

> Hello, I would like to report the following issue:
> This seems to be related to double numbers' [...]

What every *programmer* should know about floating point:

<https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html>

Yes, it's definitely a known issue... ;)

HTH,

Julio

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor