Re: Reading VB data

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Mon, 24 May 1999, Boehme, Gabriel wrote:

> Irv Mullins wrote:
>
> >>>I have some accounting data written with Visual Basic.
> >>>The numbers are 8 bytes (reals, I guess).
> >>>Can anyone tell me how to read these with Euphoria?
> >Sure would appreciate some help !

<snip sample output>

> I think I've got it. Believe it or not, those are actually 64-bit signed
> *integer* values. To get VB's dollar amount, divide the integer value by
> 10,000. Here's a quick solution which should work for dollar values in the
> range abs(x) <= $214,748.3647:
>
>  -----------
> include machine.e
>
> function VBfloat_to_atom(sequence s) -- our 8-byte sequence
>  -- works for values in the range abs(x) <= 214,748.3647
> atom x
>    x = bytes_to_int(s[1..4]) -- ignore the last 4 bytes (quick fix)
>    if x > #7FFFFFFF then
>       -- handle negative value
>       x = x - #100000000  -- power(2, 32)
>    end if
>    return x / 10000
> end function
>  -----------
>
> I tested this routine for all of the above data, and the printed results
> were 100% correct! :)

Indeed it is! Thanks VERY much for the answer!

Regards,
Irv

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu