From: Yusuke Endoh Date: 2011-10-31T23:24:08+09:00 Subject: [ruby-core:40563] Re: [ruby-trunk - Feature #5321] Introducing Numeric#exact? and Numeric#inexact? Hello, 2011/10/31 Kenta Murata : > I want to create a mathematical function which behaves like 1/x. > This function is defined over real numbers except for zero, > because lim_{x -> +0} 1/x = +inf while lim_{x -> -0} 1/x = -inf. > So I want to raise Math::DomainError for the function with exact zero. > But I don't want to raise the error for inexact zeros, such as 0.0, -0.0, > BigDecimal("0"), and others which are instances of classes I don't know. > > If Numeric#inexact? and Numeric#exact? are given, > I can realize the function more easily. Thank you for the explanation. You expect that 1/x does never raise any exception if x is an inexact number, right? I wonder if the expectation is valid. But anyway, your use case is certainly convincing for me. Thank you. -- Yusuke Endoh