From: Thomas Lundqvist Date: 2001-05-01T07:10:03+09:00 Subject: [ruby-talk:14457] Re: gtk and Float/to_f On Mon, 30 Apr 2001, Yukihiro Matsumoto wrote: > Hi, > > In message "[ruby-talk:14339] gtk and Float/to_f" > on 01/04/28, Thomas Lundqvist writes: > > |Hi! I experience the following strange behavior: > | > |> ruby -e 'puts "5.3".to_f + 1.0' > |6.3 > | > |> ruby -e 'require "gtk"; puts "5.3".to_f + 1.0' > |6.0 > > Weird. Platform information, please? > Nothing changes on ruby 1.6.3 (2001-03-28) [i386-linux]. > > matz. Ok! I solved it! I live in Sweden. Gtk uses setlocale and changes the numeric format to 5,3 instead of 5.3. For example: > setenv LANG sv_SE > ruby -e 'require "gtk"; puts "5.3".to_f + 1.0' 6.0 > setenv LANG C > ruby -e 'require "gtk"; puts "5.3".to_f + 1.0' 6.3 But a better solution is: > setenv LANG sv_SE > setenv LC_NUMERIC C > ruby -e 'require "gtk"; puts "5.3".to_f + 1.0' 6.3 I don't like it when basic libc-functions (strtod) is changed by the locale. I want my programs to work in other countries as well. The function strtod should really come in two flavours. One depending on the locale and one not depending... Regards, Thomas ----------------------------------------------------------------------- Thomas Lundqvist, Ph.D. Student thomasl@ce.chalmers.se Dept. of Computer Engineering http://www.ce.chalmers.se/~thomasl/ Chalmers University of Technology SE-412 96 Gothenburg Phone: +46 31 772 1165 SWEDEN Fax: +46 31 772 3663 -----------------------------------------------------------------------