From: Sebastian Hungerecker Date: 2009-07-27T01:59:35+09:00 Subject: Re: Possible bug in rb_float_new() ??? Am Sonntag 26 Juli 2009 18:11:48 schrieb Francisco Tufró: > Hi, when writing the ruby bindings for libsndfile i had a problem with > float numbers. > I have abstracted the important code and i put it right here, is > something i'm doind not right or a bug? > You can check the code at: http://pastebin.com/m6c5f3ed1 The problem has nothing to do with rb_float_new. As I said on IRC, you're storing the double you get from ruby into an array of floats. By doing that you implicitly cast the double to float and since floats are less accurate than doubles, you lose precission. When converting back from float to double, you of course won't get that precission back, so the number that comes out is not the same one that came in. HTH, Sebastian