From: Heesob Park Date: 2009-03-02T22:51:50+09:00 Subject: [ruby-core:22623] Re: suggestions for float > From: Yukihiro Matsumoto > To: ruby-core@ruby-lang.org > Date: Mon, 2 Mar 2009 19:46:27 +0900 > Subject: [ruby-core:22621] Re: suggestions for float > Hi, > > In message "Re: [ruby-core:22595] Re: suggestions for float" > on Sun, 1 Mar 2009 01:22:29 +0900, Roger Pack writes: > > |I guess there's not too much feedback on this one :) > > We are not ignoring you. We just lack for resource working on the > proposal right now. We welcome a patch to make > > some_float == eval("#{some_float}") > > to be always true. Lua do the job as following definition: #define LUA_NUMBER_FMT "%.14g" #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) #define lua_str2number(s,p) strtod((s), (p)) In my test with ruby float, %.14g is not enough, %.20g is suitable. It will written with Ruby code as like this: string = ('%.20g.0' % some_float).sub(/(\.\d+)(\.0)$/,'\1') some_float == eval(string) Regards, Park Heesob