[#22684] [Bug #1247] YAML::load converts some dates into strings — Matthew Wilson <redmine@...>

Bug #1247: YAML::load converts some dates into strings

10 messages 2009/03/05

[#22725] [Bug #1253] Fix MSVC Build Issues — Charlie Savage <redmine@...>

Bug #1253: Fix MSVC Build Issues

13 messages 2009/03/07

[#22727] Moving ruby 1.9.1 forward on windows — Charlie Savage <cfis@...>

Hi everyone,

14 messages 2009/03/08

[#22731] [Bug #1255] += for large strings egrigiously slow — James Lee <redmine@...>

Bug #1255: += for large strings egrigiously slow

11 messages 2009/03/08

[#22736] Ruby 1.9.1 and tail recursion optimization — =?ISO-8859-15?Q?Wolfgang_N=E1dasi-Donner?= <ed.odanow@...>

Moin, moin!

13 messages 2009/03/08
[#22739] Re: Ruby 1.9.1 and tail recursion optimization — =?ISO-8859-15?Q?Wolfgang_N=E1dasi-Donner?= <ed.odanow@...> 2009/03/08

Wolfgang N疆asi-Donner schrieb:

[#22748] [Feature #1256] Add constant TAILRECURSION to let a program recognize if tail recursion optimization is implemented — Wolfgang Nádasi-Donner <redmine@...>

Feature #1256: Add constant TAILRECURSION to let a program recognize if tail recursion optimization is implemented

7 messages 2009/03/08

[#22803] Relegate 1.8.6 to Engine Yard, part II — Urabe Shyouhei <shyouhei@...>

Hello and sorry for my being slow for this issue. It's OK now for me to pass

21 messages 2009/03/10

[#22812] [Bug #1261] cross-compiling Ruby extensions using mkmf doesn't fully respect DESTDIR — Daniel Golle <redmine@...>

Bug #1261: cross-compiling Ruby extensions using mkmf doesn't fully respect DESTDIR

8 messages 2009/03/10

[#22892] Ruby Time — valodzka <valodzka@...>

Got tired of current ruby Time limitation, I have written this -

24 messages 2009/03/14
[#22949] Re: Ruby Time — Tanaka Akira <akr@...> 2009/03/19

In article <9e19ed87-9d12-4f98-af3c-bd49a71b0bd4@p11g2000yqe.googlegroups.com>,

[#22974] Re: Ruby Time — valodzka <valodzka@...> 2009/03/20

[#22977] Re: Ruby Time — Urabe Shyouhei <shyouhei@...> 2009/03/20

valodzka wrote:

[#22981] Re: Ruby Time — valodzka <valodzka@...> 2009/03/21

> I bet you'll get tired of updating that database. There's a major difference

[#22893] [Feature #1291] O_CLOEXEC flag missing for Kernel::open — David Martin <redmine@...>

Feature #1291: O_CLOEXEC flag missing for Kernel::open

10 messages 2009/03/15

[#22939] [Bug #1303] A name considered a local variable on RHS of an assignment that defines it — Tomas Matousek <redmine@...>

Bug #1303: A name considered a local variable on RHS of an assignment that defines it

8 messages 2009/03/19

[#23063] [Bug #1332] Reading file on Windows is 500x slower then with previous Ruby version — Damjan Rems <redmine@...>

Bug #1332: Reading file on Windows is 500x slower then with previous Ruby version

11 messages 2009/03/30

[#23075] [Bug #1336] Change in string representation of Floats — Brian Ford <redmine@...>

Bug #1336: Change in string representation of Floats

37 messages 2009/03/31
[#23179] [Bug #1336] Change in string representation of Floats — Roger Pack <redmine@...> 2009/04/11

Issue #1336 has been updated by Roger Pack.

[#23181] Re: [Bug #1336] Change in string representation of Floats — Brent Roman <brent@...> 2009/04/11

[#23186] Re: [Bug #1336] Change in string representation of Floats — Yukihiro Matsumoto <matz@...> 2009/04/12

Hi,

[#23187] Re: [Bug #1336] Change in string representation of Floats — Brent Roman <brent@...> 2009/04/13

[#23188] Re: [Bug #1336] Change in string representation of Floats — Yukihiro Matsumoto <matz@...> 2009/04/13

Hi,

[ruby-core:22639] Re: suggestions for float

From: Heesob Park <phasis@...>
Date: 2009-03-03 09:13:35 UTC
List: ruby-core #22639
2009/3/3 Brent Roman <brent@mbari.org>:
>
> OK. =C2=A0I apologize in advance. =C2=A0Soapbox on...
>
> I, for one, like Ruby's current approach to numeric type conversions.
> There is an automatic promotion from Fixnum to Bignum to prevent =C2=A0ov=
erflow.
> (a nice feature borrowed from SmallTalk)
>
> However, as others have pointed out, there is no analogous promotion betw=
een
> discrete, countable Integer types and Floats. =C2=A0This is because all F=
loats
> are *approximations* of abstract, continuous Real numbers.
>
> Floats are imprecise by design. =C2=A0They are intended to represent meas=
ured
> quantities, not countable objects. =C2=A0Any real valued measurement is l=
ikely to
> have more error in its underlying physics than the 8-byte binary floating
> point format Ruby uses to approximate that value.
>
> Floats should not be used for counting *anything* discrete. =C2=A0Not pen=
nies,
> not array elements, not machine states. =C2=A0(ok, maybe pennies if you a=
re
> dealing with current stock prices :-)
>
> Sure, they can approximate 1.0 fairly well. =C2=A0But, 1.1 is an inexact
> repeating binary fraction.
>
> A variant of the float to string conversion that tries to preserve all th=
e
> binary information would certainly be useful, but not as the default to_s
> method. =C2=A0That is, unless you think that:
>
> irb> =C2=A02.1 - 3.0
> -0.8999999999999999
>
> would not be "surprising"! =C2=A0(well, at least annoying)
>
> Then, of course, there remains the question of efficiency. =C2=A0Many sim=
ple
> iterative numerical algorithms will cause BigDecimal and Rational numbers=
 to
> balloon in bytes required as they struggle to maintain perfect accuracy.
> And, as they become bigger in memory, they will also become slower. =C2=
=A0Think
> of numerical integration, for example, =C2=A0or most any sort of successi=
ve
> approximation, in general.
>
> But, theoretical niceties aside, most plain folks are surprised when thei=
r
> fancy computer says:
>
> =C2=A0 2.1 - 3.0 =C2=A0!=3D -0.9
>
> What would fix this problem while still preserving efficiency and keep us
> numerical nerds happy?
>
One possible fix is something like this:

class Float
  alias :plus :+
  alias :minus :-
  def +(a)
    self.plus(a).to_s.to_f
  end
  def -(a)
    self.minus(a).to_s.to_f
  end
end

irb> 2.1 - 3.0 =3D=3D -0.9
=3D> true

Regards,

Park Heesob

In This Thread