From: Alex Young Date: 2012-11-02T00:34:12+09:00 Subject: [ruby-core:48711] Re: [ruby-trunk - Feature #6973] Add an #integral? method to Numeric to test for whole-number values On 31/10/12 13:03, alexeymuranov (Alexey Muranov) wrote: > > Issue #6973 has been updated by alexeymuranov (Alexey Muranov). > > > regularfry (Alex Young) wrote: > >> >> So if I knowingly and correctly construct a calculation which cannot >> contain such an error, Ruby should tell me that it's wrong? >> > > Alex, can you give an example, please? Trivially? x * 2.0 for x small enough not to overflow. There's a more interesting vein of examples where this sort of thing crops up if you google for "error-free transformations", like the 2Sum and Fast2Sum algorithms. -- Alex > > ---------------------------------------- > Feature #6973: Add an #integral? method to Numeric to test for whole-number values > https://bugs.ruby-lang.org/issues/6973#change-32110 > > Author: regularfry (Alex Young) > Status: Assigned > Priority: Normal > Assignee: mrkn (Kenta Murata) > Category: core > Target version: next minor > > > Numeric#integer? checks whether an instance is an Integer. It is often useful to check whether the value of a non-Integer variable is actually a whole number, and the #integer? method doesn't help here. > > This patch adds Numeric#integral?, which performs this check. > >