On Nov 27, 2011, at 12:55 AM, Charles Srstka wrote: > On Nov 26, 2011, at 5:44 PM, Koen van der Drift wrote: > > Another thing that might be a good idea for general safety reasons is to have > f be a Float32 instead of a regular float type.
This will only work if we can safely assume the sender is using 4 byte floats. This cannot be guaranteed, since the size of floats is platform dependend. So, *if possible* I would recommend to send these floats as decimal strings and then convert these number strings to whatever math type appropriate on the receiver site. There is no base64 encoding/decoding required, too. Since the posted code is obviously not designed to be efficient, the extra cost for string to double/float conversions can probably be accepted or can even be compensated by a more efficient math type on the receiver site when performing computations. > Although I don’t know how likely it is, it’s probably theoretically possible > that the float data type could eventually become something other than 32 bits > on some platform, and if that happened, doing a memcpy of sizeof(float) bytes > from a uint32_t would cause garbage data to be written to the float. Yes, this. Andreas > > Charles _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com