From: Lyle Johnson Date: 2003-05-29T05:17:48+09:00 Subject: [Q] Should I use NUM2UINT or NUM2ULONG? I'm looking at an FXRuby bug that I suspect has to do with the size differences between 32-bit and 64-bit operating systems. In FOX (the C++ library) a color value is stored as an "FXuint", which is typedef'd as a 32-bit unsigned integer. It is *always* this size, regardless of the underlying platform's sizes for ints, longs, etc. If I am presented with a Ruby Integer (which can be either a Fixnum or a Bignum) I want to convert that number to an FXuint. So far, I've been using Ruby's NUM2UINT macro for this purpose, i.e. FXColor color = NUM2UINT(value); and this works fine on my Linux and Windows boxen. But one of my users is trying the code out on a DEC box, which I'm pretty sure is a 64-bit machine, and he's getting an error when such conversions are attempted, e.g. bounce.rb:105:in `setForeground': integer 4294967295 too big to convert to `int' (RangeError) This value should fit into an unsigned integer (it is equal to UINT_MAX) but the error message indicates that it's trying to convert it to an 'int' instead. I'm still waiting on some additional information from this user, but I'm guessing that SIZEOF_INT is less than SIZEOF_LONG in "config.h", and so the NUM2UINT gets expanded to NUM2INT. And the value (4294967295) is too big to fix into a signed integer, and so an exception is raised. So now I'm wondering, should be using NUM2ULONG for this conversion instead? I think it's probably a bug that NUM2UINT gets this wrong, but at this point I just want something that will work correctly. Thanks for any suggestions, Lyle