From: "Victor H. Goff III" Date: 2008-08-28T12:23:47+09:00 Subject: Re: BigDecimal with Float comparision bug. ------=_Part_31503_21445132.1219894100863 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline The simple test comparing BigDecimal.new('25') == 25.0 is true, but BigDecimal.new('24') == 24.0 is false. The numbers from 1 to 1000 that don't test like the rest of them on my system are: [3, 6, 12, 13, 21, 24, 26, 29, 31, 42, 45, 48, 51, 52, 55, 58, 61, 62, 69, 79, 84, 87, 90, 93, 96, 99, 101, 102, 104, 107, 110, 113, 116, 119, 121, 122, 124, 127, 138, 157, 158, 163, 168, 169, 174, 175, 180, 181, 185, 186, 191, 192, 197, 198, 202, 203, 204, 208, 209, 214, 215, 220, 221, 225, 226, 227, 231, 232, 237, 238, 242, 243, 244, 248, 249, 254, 255, 259, 276, 293, 299, 314, 316, 319, 321, 326, 331, 333, 336, 338, 343, 345, 348, 350, 353, 355, 360, 362, 365, 367, 370, 372, 377, 379, 382, 384, 387, 389, 394, 396, 399, 401, 404, 406, 408, 411, 413, 416, 418, 421, 423, 425, 428, 430, 433, 435, 440, 442, 445, 447, 450, 452, 454, 457, 459, 462, 464, 467, 469, 471, 474, 476, 479, 481, 484, 486, 488, 491, 493, 496, 498, 501, 503, 505, 508, 510, 518, 535, 552, 569, 581, 586, 598, 615, 627, 628, 632, 633, 637, 638, 642, 643, 647, 652, 657, 661, 662, 666, 667, 671, 672, 676, 677, 681, 686, 690, 691, 695, 696, 700, 701, 705, 706, 710, 715, 720, 724, 725, 729, 730, 734, 735, 739, 740, 744, 749, 753, 754, 758, 759, 763, 764, 768, 769, 773, 774, 778, 783, 787, 788, 792, 793, 797, 798, 802, 803, 807, 808, 812, 816, 817, 821, 822, 826, 827, 831, 832, 836, 837, 841, 842, 846, 850, 851, 855, 856, 860, 861, 865, 866, 870, 871, 875, 879, 880, 884, 885, 889, 890, 894, 895, 899, 900, 904, 905, 908, 909, 913, 914, 918, 919, 923, 924, 928, 929, 933, 934, 938, 939, 942, 943, 947, 948, 952, 953, 957, 958, 962, 963, 967, 968, 971, 972, 973, 976, 977, 981, 982, 986, 987, 991, 992, 996, 997] Just thought I would share... Running Ruby 1.8.6 on Windows. The code I used to generate the output is: failed = Array.new (1..1000).each { |d| failed << d if BigDecimal.new("#{d}.0") != d.to_f } p failed The doctest code I used for testing for 24 is: # doctest: Testing BigDecimal # >> BigDecimal.new('24.0') == 24 # => true # >> BigDecimal.new('24.0') == 24.0 # => false # end This passes, so indicates what is happening. Why? I don't know. On Wed, Aug 27, 2008 at 9:15 PM, Shin guey Wong wrote: > It works in my ruby in windows :) > > irb(main):003:0> BigDecimal.new("25.0") == 25.0 > => true > irb(main):004:0> BigDecimal.new("25.0") == 25 > => true > irb(main):005:0> exit > > C:\ruby --version > ruby 1.8.6 (2008-07-17 patchlevel 279) [i386-mingw32] > > > ------=_Part_31503_21445132.1219894100863--