yeluolei / hessianphp

Automatically exported from code.google.com/p/hessianphp
MIT License
0 stars 1 forks source link

pb with float value with as3 client #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Thanks a lot for providing this wonderful library. It works all right for me 
except for float values (running as3 client)

I have an object in php and as3 :
//php
class DataObj
{
  var $intval=0;
  var $stringval="";
  var $boolval=false;
  var $floatval=0;
  var $list=array();
}
//as3
package DataPack
{
  public class DataObj
  {
    public var intval:int=0;
    public var stringval:String="";
    public var boolval:Boolean=false;
    public var floatval:Number=0;
    public var list:Array=new Array;
    //
    public var hessianTypeName:String="DataPack.DataObj";
  }
}

And I test data exchanges :
  // php hessian server function
  function GetObject()
  {
    $obj=new DataObj();
    //change some values
    $obj->list[]=new DataObj();
    return($obj);
  }

using option :
$options->typeMap = array('DataObj' => 'DataPack.DataObj');

The as3 program receives all data correctly including recursive lists, but the 
float value is always wrong as soon as it is not integer in the php side.
If I set floatval=6.3 in php, I receive 3.0587364693705485e-57 in as3

When I test the other direction, setting floatval 6.2 in as3 :
  function SetObject($obj)
  {
    $obj->floatval*=2;
    return($obj);
  }

as3 receives back the value 6.200000000003638 instead of 12.4

I use hessian-php-2.0.3 on the server and hessian-flex-3.2.0.snap080821.swc on 
the client (wich works great with a java server) and I compile the client with 
flash builder 4.5

I do not set the hessian protocole version.
All unit test work correctly in v1 and v2.
All this runs on macosx 10.6 with native apache/php

Thanks for your help
I can provide a simple test (but you need flash builder 4.5 to compile it)

Original issue reported on code.google.com by architec...@gmail.com on 7 Jul 2011 at 1:59

GoogleCodeExporter commented 9 years ago
just for your information if you stumble across this - it's linked to the issue 
11 (little endian check)... had to reverse the double bits (on my android 
client) because the server developer didnt want to touch the library... so just 
implement the solution in issue 11 server side or send the bits in reverse!

Original comment by wolfram....@gmail.com on 4 Sep 2012 at 1:24

GoogleCodeExporter commented 9 years ago
Thanks a lot for this information. I'll think about it for my php/flex project.
Riccardo

Original comment by architec...@gmail.com on 4 Sep 2012 at 1:54