float

60 views
Skip to first unread message

charlie

unread,
Jul 15, 2010, 6:38:10 AM7/15/10
to PhpForAndroid
I posted this also in the ASE-Group but maybe here is the better
place.
I want to port some of my PHP-scripts I already have to my android
phone. These scripts are mainly used for mathemathical issues, and
therefore I discoverd that PFA cannot handle the float-type.

For example, "echo 10/5;" gives the correct result but "echo 10/6;"
just brings up "[1] + Stopped (signal)" without any result.

Is this a known issue? Is there are workaround for this?

regards, charlie

Anton Perkin

unread,
Jul 15, 2010, 6:40:19 AM7/15/10
to php-for...@googlegroups.com
I've also experienced such problems, but do not have the solution for now.


--
You received this message because you are subscribed to the Google Groups "PhpForAndroid" group.
To post to this group, send email to php-for...@googlegroups.com.
To unsubscribe from this group, send email to php-for-andro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/php-for-android?hl=en.




--
Best regards,
Anton Perkin,
Project manager, Senior developer

Ivan Mosquera Paulo

unread,
Jul 15, 2010, 6:44:41 AM7/15/10
to PhpForAndroid
We'll check it out. The built in php source is a bit tweaked to be
able to link against bionic. There might be a bug because of that. If
you find a workaround, let us now.

--
Iván Mosquera Paulo
Irontec, Internet y Sistemas sobre GNU/LinuX - http://www.irontec.com
+34 94.404.81.82
phpforandroid.net
twitter.com/ivmos

Ivan Mosquera Paulo

unread,
Jul 15, 2010, 6:53:35 AM7/15/10
to PhpForAndroid
Seems like We commented the echo float function. So, internally the
floats should be working. Try to echo its value with ASE's api instead
of php's echo please. I know that It's a dirty workround but We might
not have time to address this issue today.

Thanks in advance

On Jul 15, 12:44 pm, Ivan Mosquera Paulo <i...@irontec.com> wrote:
> We'll check it out. The built in php source is a bit tweaked to be
> able to link against bionic. There might be a bug because of that. If
> you find a workaround, let us now.
>
> --
> Iván Mosquera Paulo
> Irontec, Internet y Sistemas sobre GNU/LinuX -http://www.irontec.com
> +34 94.404.81.82
> phpforandroid.net
> twitter.com/ivmos

Ivan Mosquera Paulo

unread,
Jul 15, 2010, 9:06:01 AM7/15/10
to PhpForAndroid
Seems like my proposed workaround doesn't work so We might replace the
binary. If

Javier Infante

unread,
Jul 15, 2010, 9:50:07 AM7/15/10
to php-for...@googlegroups.com
Hi!

I have tried to echo using both (string)$val and number_format($val),
but it's not working on my android...

So I just wrote a dirty little function which seems to be working:

function float2string($value,$decimal_sign = "." ,$no_decs) {
return (int)$value . ( ($no_decs > 0)?
$decimal_sign .(int)(fmod($value,((int)$value)) * pow(10,$no_decs))
:
'');
}

$v = 5/4;
echo flaot2string($v,".",2);
// Will echo 1.25

Hope it helps until we wait for the next release with this issue solved.

Cheers!

--
Javier Infante Porro

Ivan Mosquera Paulo

unread,
Jul 15, 2010, 11:25:40 AM7/15/10
to PhpForAndroid

>
> So I just wrote a dirty little function which seems to be working:
>
> function float2string($value,$decimal_sign = "." ,$no_decs) {
>   return (int)$value . ( ($no_decs > 0)?
> $decimal_sign .(int)(fmod($value,((int)$value)) * pow(10,$no_decs))
>   :
>   '');
>
> }
>
> $v = 5/4;
> echo flaot2string($v,".",2);
> // Will echo 1.25
>
> Hope it helps until we wait for the next release with this issue solved.
>

Great!

I've started a page about known issues and its workarounds:
http://phpforandroid.net/releases:known_issues
and a draft with some kind of roadmap: http://phpforandroid.net/roadmap

@Charlie, can you go on with this workaround?


Regards.

--
Iván Mosquera Paulo
Irontec, Internet y Sistemas sobre GNU/LinuX - http://www.irontec.com
+34 94.404.81.82
phpforandroid.net
twitter.com/ivmos

charlie

unread,
Jul 21, 2010, 3:36:27 AM7/21/10
to PhpForAndroid
Thank you all for your help! I ported the first script now to perl and
as soon as I find a way to use both perl and php in one SL4A package I
will try PFA again.
> Irontec, Internet y Sistemas sobre GNU/LinuX -http://www.irontec.com
> +34 94.404.81.82
> phpforandroid.net
> twitter.com/ivmos
Reply all
Reply to author
Forward
0 new messages