Issue #2968 has been updated by yhara (Yutaka HARA). Target version set to next minor ---------------------------------------- Feature #2968: 数値の正負を返すメソッド https://bugs.ruby-lang.org/issues/2968#change-31815 Author: naruse (Yui NARUSE) Status: Assigned Priority: Normal Assignee: mrkn (Kenta Murata) Category: core Target version: next minor =begin 数値の正負を返すメソッドが欲しいです。 主たる想定用途は 0.0 と -0.0 を区別したいときです。 これは、0.0 > -0.0 や 0.0 == -0.0 では知ることができません。 とりあえず flo.to_s[0] == ?- で知ることができますが、これではあんまりです。 悩みどころはいつもの通りメソッド名ですが、 * Numeric#positive? と Numeric#negative? * Numeric#sign -> 負で -1、正で 1 * Numeric#sign? -> 負で true, 正で false (signbit(3) に習う) あたりでしょうか。 いかがでしょう。 =end
on 2012-10-27 17:09
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.