From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id F0AF81F66E for ; Tue, 11 Aug 2020 14:40:53 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4598D1209E0; Tue, 11 Aug 2020 23:40:22 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id C59061209DD for ; Tue, 11 Aug 2020 23:40:18 +0900 (JST) Received: by filterdrecv-p3mdw1-canary-6c6ff5ff56-ngzws with SMTP id filterdrecv-p3mdw1-canary-6c6ff5ff56-ngzws-19-5F32ADEF-F 2020-08-11 14:40:47.146835646 +0000 UTC m=+1114343.078430134 Received: from herokuapp.com (unknown) by ismtpd0090p1iad2.sendgrid.net (SG) with ESMTP id SOqoChV-QIWfB4O_EPY3rQ for ; Tue, 11 Aug 2020 14:40:47.068 +0000 (UTC) Date: Tue, 11 Aug 2020 14:40:47 +0000 (UTC) From: pdahorek@seznam.cz Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75382 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17114 X-Redmine-Issue-Author: tammo X-Redmine-Sender: ahorek X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?FEBmdr4t2oPyVtJ=2FHwsoNw3OX6yEJVN29QfUTo2MyNMcxd923o4Lf7cDksAwl5?= =?us-ascii?Q?NLzXK6rOEtmmo6oj0BiCfFvSe7lIgBLVOmJSzu=2F?= =?us-ascii?Q?dU+o3AN1uhBPzrI3L+cAxzb1dUCdhlAPO+6MnFM?= =?us-ascii?Q?o+CvlWQx0zfz=2FqYSP4BDObnukrwy34LKF4iGER+?= =?us-ascii?Q?urfv9kbJmTnkfKQGAg7uy=2F4ArougR0f7l756Tn6?= =?us-ascii?Q?rARreEnamtV0K99Ac=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99557 Subject: [ruby-core:99557] [Ruby master Bug#17114] Float is not properly kept as integer when integer is added without space X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17114 has been updated by ahorek (Pavel Rosick=FD). Hi, it's not a bug. +-1 is a precision argument. ``` irb> 12.34.floor(-1) =3D> 10 irb> 12.34.floor(+1) =3D> 12.3 ``` take a look at the documentation, it describes this exact behavior well. https://ruby-doc.org/core-2.7.1/Float.html#method-i-floor Returns a floating point number when ndigits is positive, otherwise returns= an integer. ---------------------------------------- Bug #17114: Float is not properly kept as integer when integer is added wit= hout space https://bugs.ruby-lang.org/issues/17114#change-87017 * Author: tammo (tammo tjarks) * Status: Rejected * Priority: Normal * ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- Hello dear ruby community, I observed the following strange behaviour (maybe it is intended) in Versio= n 2.6.3p62: ruby -v ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] In pry I can see: ``` ruby [7] pry(main)> 1.0.floor +1 =3D> 1.0 [8] pry(main)> (1.0).floor +1 =3D> 1.0 [9] pry(main)> (1.0.floor) +1 =3D> 2 [10] pry(main)> 1.0.floor + 1 =3D> 2 ``` I think the reason is, that +1 is taken as argument to floor. Anyway, it is= strange, that 1.0.floor is integer but 1.0.floor +1 again a float. Is this= intended behaviour. I have not the lates ruby version installed, so I do n= ot know if it may be changed. Also I observed it only with +1. With -1 I ge= t: ``` ruby [8] pry(main)> 1.0.floor -1 =3D> 0 ``` Best regards, Tammo -- = https://bugs.ruby-lang.org/ Unsubscribe: