Ask a Question related to Ruby, Design and Development.
-
Mark J. Reed #1
Rational#to_i inconsistent with Float#to_i
Float#to_i rounds toward zero; Rational#to_i rounds down (is equivalent
to Rational#floor). This is inconsistent and complicates the
replacing of Floats with Rationals for added precision in existing
code. Was this an intentional design decision?
irb(main):001:0> require 'rational'
=> true
irb(main):002:0> r = Rational(-7,2)
=> Rational(-7, 2)
irb(main):003:0> puts r.to_i, r.to_f.to_i
-4
-3
=> nil
irb(main):004:0>
-Mark
Mark J. Reed Guest
-
Destructive type conversion (to_i!, to_f!)
Hi, There have been a few times in which I have wanted to destructively change the type of a variable, yet as fas I can determine there are only... -
to_i
Hi, taken from the ruby book: str.to_i -> anInteger Returns the result of interpreting leading characters in str as a decimal integer.... -
#25562 [Opn->Bgs]: Float to String to Float conversion error
ID: 25562 Updated by: helly@php.net Reported By: daseymour at 3hc dot org -Status: Open +Status: ... -
#25562 [NEW]: Float to String to Float conversion error
From: daseymour at 3hc dot org Operating system: and PHP version: 4.3.3 PHP Bug Type: Math related Bug description: Float... -
my code has gone complete mad and no longer does anything rational
Maybe its late and I'm tired but I don't understand what I'm seeing on the screen. I have this block of code: $choiceMade = $_GET; if...



Reply With Quote

