Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: retrieving values in binary files

From: g:santilli:tiscalinet:it at: 1-Oct-2002 20:08

Hi Hugues, On Tuesday, October 1, 2002, 4:08:44 PM, you wrote: HM> I can easily retrieve integer values stored in big-endian or little-endian format, HM> but an don't know how to retrieve floating values stored as floats or doubles HM> in binary format (big-endian or HM> little-endian). I think the internal format used by REBOL is platform dependent. However, if you happen to have your values in the same format used by REBOL you can convert them very quickly with something like:
>> s: make struct! [num [decimal!]] [0.0] >> third s
== #{0000000000000000}
>> s/num: 1.0
== 1
>> third s
== #{000000000000F03F}
>> s/num: 150.3
== 150.3
>> third s
== #{9A99999999C96240}
>> change third s #{000000000000F03F}
== #{}
>> s/num
== 1 This should also give you hints on how DECIMAL! is implemented on your platform. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r