In my Decimal Plugin I am adding conversion routines between the  
Currency type of REALbasic and my Decimal type. Xcode created a  
Universal dylib which works well. So I took the same source files and  
used Terminal in Ubuntu Linux to make a .so library. And I did the  
same to make a .DLL library using MinGW and MSYS under Windows XP.

Using test applications, I find the conversions are done correctly  
under OS X on both a G4 Mac and an Intel Mac (using the same Universal  
application). The conversions are also done correctly with a Linux  
application running under Ubuntu.

But the windows application did not convert correctly. So I wrote this  
RB program:

   dim c, c1 As Currency
   dim d, d1 As Decimal
   DecSetScale(4)
   c = Cdbl(EditFieldx.text)
   d = new Decimal(EditFieldx.text)
   c1 = DecimalToCurrency(d)
   d1 = DecimalFromCurrency(c)
   EditFieldz.text = "c = " + Format(c, "-###,###.####") + "  c from d  
= " + Format(c1, "-###,###.####")
   EditFieldy.text = "d = " + str(d) + "  d from c = " + str(d1)

Basically the conversion is accomplished in the plugin by passing a  
long long to/from RB. So, thinking that it might be a byte ordering  
problem, I used a long long in Hex:
$0000112233445566 = 18838586676582 in decimal

So I put 1883858667.6582 in EditFieldx. For OS X and Ubuntu all  
resulting numbers exactly agreed with the input number. But for Windows:

c = 1,883,858,667.6582
d = 1883858667.6582
c from d = 86,011.6326
d from c = 86011.6326

The underlying conversion integer, 860116326, is the same for both  
directions. And translated into Hex it is $33445566.

So it is clear what is happening. When I pass $0000112233445566 in  
either direction, only the lower 32 bits are passed.

How is it that passing a long long, which should be 64 bits, results  
in only the lower half being passed? The exact same code for OS X and  
Linux clearly passes all 64 bits.

My own guess is that MinGw does not have a 64 bit integer type, so it  
treats a long long as a long. But there were no warnings about this in  
the make.

Does anyone have some further insight as to what might be happening  
here?

Thanks.
Bob

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to