[#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:22705] Re: suggestions for float

From: Roger Pack <rogerdpack@...>
Date: 2009-03-06 23:52:18 UTC
List: ruby-core #22705
> 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. =A0That is, unless you think that:
>
> irb> =A02.1 - 3.0
> -0.8999999999999999
>
> would not be "surprising"! =A0(well, at least annoying)

At least users would be able to understand this:
>> 2.1 - 3.0
=3D> -0.9
>> (2.1-3.0) =3D=3D -0.9
=3D> false

Since it would become
>> 2.1 - 3.0
=3D> -0.8999999999999
>> (2.1-3.0) =3D=3D -0.9
=3D> false

I'd prefer the second--at least I'm reminded as to what's going on and
don't have to constantly pester ruby talk with questions like "is this
normal?" :)

However, this would seem surprising
>> 0.9
=3D>  0.90000000000000002

It seems slightly more annoying and verbose but more honest.
That being said, as someone above mentioned, the current float default
output is to "prettify" by stripping the ending few bits [I guess].
Perhaps we should keep this around as a new method name.  Like
to_human_string or something [?]

> One very elegant fix would be to invent a DecimalFloat type. =A0It would =
have
> limited precision, as Floats do, but 0.1 would be represented precisely, =
as
> we finger counting humans expect it to be. =A0I've never seen this implem=
ented
> in any other language. =A0It would be a cool experiment.

That would be way cool.  Something that elegantly "became" BigDecimal
whenever it hit possible loss of precision.  My guess is that this
would be almost immediately for almost everything, though :)

Ex:
>> 0.5.class
=3D> Float
>> 0.9.class
=3D> BigDecimal




>
> What most numerical methods folks do in practice, is to define equality o=
f
> floats over an epsilon interval that is context dependent. =A0So, if you
> insist on counting dollars with Floats, any values equal to within 1/2 a
> penny (or 0.005 dollars) might be considered "equal" for all practical
> purposes. =A0Still, it's a pain to have to specify the epsilon all the ti=
me.
> Here's one way to avoid that:
>
> require 'delegate'
> class Money < DelegateClass(Float)
> =A0Epsilon =3D 0.005
>
> =A0def <=3D> other
> =A0 =A0diff =3D self - other
> =A0 =A0return -1 if diff > Epsilon
> =A0 =A0return 1 if diff < -Epsilon
> =A0 =A00
> =A0end
>
> =A0def initialize dollars
> =A0 =A0super dollars.to_f
> =A0end
> end

That would be an option.  By default use an epsilon of some quantity.
The only problem with this is the one you pointed out--...who can
determine a default epsilon?

I'm thinking that for now making the default string output be one s.t.
some_float =3D=3D eval("#{some_float}")
would be good [and possibly retaining the 'human readable' through
some other name, not even to be used with inspect, just something not
existing].
Thoughts?
-=3Dr

In This Thread