|
|
| Author |
Message |
|
| Guest |
Posted: Wed Sep 12, 2007 5:53 am |
|
|
|
Guest
|
Hi
I'm a bit worried about the mysql-driver code for the floats. It
contains this code to make a string out of float:
encode(Val, false) when is_float(Val) ->
[Res] = io_lib:format("~w", [Val]),
Res;
Now, my erlang does this
5> B = 4.4345345345.
4.43453
6> float_to_list(B).
"4.43453453450000001368e+00"
7> io_lib:format("~w~n", [B]).
["4.43453","\n"]
Which is also what the manual says, default precision of 6 ... Which
is may work, if you don't do any accounting (which should be done in
integers, I know. But some data may need the precision ...)
Jouni
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Fri Sep 14, 2007 5:14 am |
|
|
|
Guest
|
Thanks for reporting. I'll see if the io_lib api allows you to set the
precision (I think it can)
Yariv
On 9/11/07, Joneksi <Jouni.Ryno@gmail.com> wrote:
>
> Hi
>
> I'm a bit worried about the mysql-driver code for the floats. It
> contains this code to make a string out of float:
>
> encode(Val, false) when is_float(Val) ->
> [Res] = io_lib:format("~w", [Val]),
> Res;
>
> Now, my erlang does this
> 5> B = 4.4345345345.
> 4.43453
> 6> float_to_list(B).
> "4.43453453450000001368e+00"
> 7> io_lib:format("~w~n", [B]).
> ["4.43453","\n"]
>
> Which is also what the manual says, default precision of 6 ... Which
> is may work, if you don't do any accounting (which should be done in
> integers, I know. But some data may need the precision ...)
>
>
> Jouni
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Sat Sep 15, 2007 5:05 am |
|
|
|
Guest
|
Why not to use float_to_list? It does use the full precision. And as
you use is_float() to check, that parameter is indeed a float.
Jouni
On Sep 14, 8:14 am, "Yariv Sadan" <yarivsa...@gmail.com> wrote:
> Thanks for reporting. I'll see if the io_lib api allows you to set the
> precision (I think it can)
>
> Yariv
>
> On 9/11/07, Joneksi <Jouni.R...@gmail.com> wrote:
>
>
>
> > Hi
>
> > I'm a bit worried about the mysql-driver code for the floats. It
> > contains this code to make a string out of float:
>
> > encode(Val, false) when is_float(Val) ->
> > [Res] = io_lib:format("~w", [Val]),
> > Res;
>
> > Now, my erlang does this
> > 5> B = 4.4345345345.
> > 4.43453
> > 6> float_to_list(B).
> > "4.43453453450000001368e+00"
> > 7> io_lib:format("~w~n", [B]).
> > ["4.43453","\n"]
>
> > Which is also what the manual says, default precision of 6 ... Which
> > is may work, if you don't do any accounting (which should be done in
> > integers, I know. But some data may need the precision ...)
>
> > Jouni
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---
Post recived from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|