On Aug 12, 2009, at 12:09 AM, Igor Peshansky wrote:

> You neglected to mention whether you're using the C++ backend or the  
> Java
> one.

Java

>  Regardless, I think I've found your problem:
>
>>   static def getDouble( reader: FileReader ) : Double throws
> IOException {
>>      val byte0 = reader.read(); Console.OUT.printf(" %X\t", byte0);
>        ^^^^^^^^^
> The inferred type of byte0 is Int (since that's what reader.read()
> returns).

Reader class method read() appears to read a Byte
InputStream class method read() appears to read an Int
InputStreamReader class method read() appears to read a Byte

With no documentation in the source code things become rather  
perplexing.

>
>>      val ret1 = ( ((byte7&0xff)<<56) | ((byte6&0xff)<<48) |
> ((byte5&0xff)<<40) | ((byte4 & 0xff)<<32) );
>        ^^^^^^^^
> Ditto for the inferred type of ret1 (since the whole expression is  
> using
> Ints).
>
>>      return Double.fromLongBits((ret0|ret1) as Long);
>                                               ^^^^^^^
> This cast comes too late - the value has already been truncated by  
> this
> point.
>
> I think the solution is to explicitly specify the type of byte0  
> through
> byte7 as Long, like this:
>
>>      val byte0: Long = reader.read(); Console.OUT.printf(" %X\t",
> byte0);
>
> etc.

This seems to fix my problem. Thanks!

>
> Any reason you are not using the Marshal approach I suggested earlier?

The Marshal class appears to read MSB. My file is LSB.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to