Re: problem with string & floats in PHP



<?php$var = '5.812E-08';var_dump($var);$var =
(float)$var;var_dump($var);var_dump($var + 2);?>Outputs:string(9)
"5.812E-08"
float(5.812E-8)
float(2.00000005812)
All you need is to cast it (float) to float, (int) to int.

Regards,
Emil Ivanov
""Pablo Luque"" <death2mtv@xxxxxxxxxxx> wrote in message
news:BAY127-F39964D791BCBD13C6A4238EE3D0@xxxxxxxxxx
Hello, Im designing a website in which I have to read some data (numbers)
from a txt file and then send this data to a function which prints a
graphic with them. When I read the data I save it in an array and the
numbers are in this format: 5.812E-08. I have read the php documentation
about it, and I have use the example given there to check which type is
the data saved in the array. The response I got is
$vectorIc[1]== 5.812E-08 type is string

I dont understand why. In the documentation it is clear that this kind of
data should be considerer float, or thats what I understood. I cant
continue with my web designing if I dont get to turn the vector elements
into float numbers, because the function that prints the graphic gives
errors when recieving strings. I would be very thankful if you could help
me trying to solve this. In using PHP 4.4.7 and Apache 2.0.59.

Thank you very much!

_________________________________________________________________
Descubre la descarga digital con MSN Music. Más de un millón de canciones.
http://music.msn.es/
.



Relevant Pages

  • Re: Abnormal program termination
    ... foo.c:4: warning: function declaration isn't a prototype ... Your version is legal under C90 rules, but int mainis more explicit ... float ave(), average; ...
    (comp.lang.c)
  • RTF Render with Scale
    ... float fHorzSizeInches = nHorzSize / 25.4f; ... IntPtr hdc = graphics.GetHdc; ... int nHorzSize = SafeNativeMethods.GetDeviceCaps(hdc, ... PHYSICALWIDTH = 110, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: RAD vs. performance
    ... work with both int and float. ... name (e.g. "+" for both int and float addition). ... Again, it's a compatibility issue. ... contend that assuming interfaces are equivalent and inferring the most ...
    (comp.lang.misc)
  • (part1b) Han from China teaches you C
    ... int flist, mlist, slist; ... float board_size; ... static void draw_tube(float bottom_radius, float top_radius, ... glVertex3f(xmin, ymin, zmax); glVertex3f; ...
    (comp.lang.c)
  • Re: RTF Render with Scale
    ... float fHorzSizeInches = nHorzSize / 25.4f; ... IntPtr hdc = graphics.GetHdc; ... int nHorzSize = SafeNativeMethods.GetDeviceCaps(hdc, ... PHYSICALWIDTH = 110, ...
    (microsoft.public.dotnet.languages.csharp)

Loading