[#290] — Florian Frank <flori@...>
Hi all,
5 messages
2002/08/03
[#297] GC longjmp macros — Michal Rokos <m.rokos@...>
Hi,
5 messages
2002/08/05
[#308] Q: OSSL in std. distr? — Michal Rokos <m.rokos@...>
Hi,
4 messages
2002/08/08
[#326] Implications of a #force_free method in Object? — Matthew Bloch <mattbee@...>
Hello;
8 messages
2002/08/19
[#328] Int vs Long — Michal Rokos <m.rokos@...>
Hi,
7 messages
2002/08/21
[#337] Int vs Long (2nd part) — Michal Rokos <m.rokos@...>
Hi,
7 messages
2002/08/22
[#340] Int vs Long #3 — Michal Rokos <m.rokos@...>
Hi,
9 messages
2002/08/22
[#344] Re: [Cleanup] Int vs Long #3
— nobu.nokada@...
2002/08/22
Hi,
[#348] Re: [Cleanup] Int vs Long #3
— Michal Rokos <m.rokos@...>
2002/08/23
Hello,
[#353] File (struct stat handling) — Michal Rokos <m.rokos@...>
Hello,
6 messages
2002/08/23
[#358] node.h for eval.c — Michal Rokos <m.rokos@...>
Hi,
5 messages
2002/08/23
[#372] rb_class_path — Michal Rokos <m.rokos@...>
Hello,
7 messages
2002/08/27
[#382] Port match to new dup, clone framework — Michal Rokos <m.rokos@...>
Hi,
5 messages
2002/08/28
[#393] in dln.c — Michal Rokos <m.rokos@...>
Hi,
14 messages
2002/08/30
[#398] Re: [MemLeak] in dln.c
— nobu.nokada@...
2002/08/31
Hi,
[#403] Re: [MemLeak] in dln.c
— Michal Rokos <m.rokos@...>
2002/09/02
Hello,
Re: Is there a bug in Matrix or Complex?
From:
GOTO Kentaro <gotoken@...>
Date:
2002-08-05 23:14:23 UTC
List:
ruby-core #299
At Tue, 6 Aug 2002 01:53:09 +0900,
Jim Freeze wrote:
> m
> Matrix[[1+2i, 3+4i], [4+2i, 3+4i]]
> m.to_f
> Matrix[[1.0+2.0i, 3.0+4.0i], [4.0+2.0i, 3.0+4.0i]]
> m.inv.inv
> Matrix[[1.0+2i, 3.0+4i], [4.0+2i, 3+4i]]
> m.inv.inv.to_f
> Matrix[[1.0+2i, 3.0+4i], [4.0+2i, 3+4i]]
> false
>
> Why does taking the double inverse let the elements
> go back to integers? And, why does #to_f not convert
> each element to a float after taking the inverse?
Elements above are floating point numbers, not integers. This odd
comes from implementation of Float#to_s which is called in `puts m'.
In ruby-1.6, x.to_s == sprintf("%.10g", x) for a Float x with
1.0e-3 <= |x| < 1.0e10.
"%.10g" doesn't format dot and following digits if number's flaction
part is not greater than 5e-11. E.g.,
#12345678901
x = 2.00000000005
x.to_s #=> "2"
sprintf("%.10g", x) #=> "2"
sprintf("%.11g", x) #=> 2.0000000001
But in ruby-1.7,
#12345678901
puts 2.00000000005
generates
2.00000000005
-- Gotoken who advised to use "%.10g" :(