Re: docs for (double) related to (int) or ???



J. Frank Parnell wrote:
On Fri, 29 May 2009 15:50:09 -0400, Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
wrote:

J. Frank Parnell wrote:
hello, I inherited this:

function microtime_float (){
list ($usec, $sec) = explode (' ', microtime ());
return (double)$usec + (double)$sec;
}

double seems to be related to int.
Can some one explain (double) or point to some docs or explanations?

thanks, J
double is just a floating point value. But this code looks bad - if it's supposed to return the microtime in seconds, it should be

return ((double)$usec) / 1000000 + double($sec);

well cool...but why double? isnt "double" ( $num * 2)? or did i miss something
in my extensive (read: high school. smirk) education?

the full usage of the function is much like in the php man(thanx yawnmoth):

$res_start = microtime_float();
//lotsa code
$res_stop = sprintf("%2f", microtime_float() - $res_start);
echo "Page load time: $res_stop seconds";

do you still believe the function to be bad?

No double is a commonly used term for floating point representations. For instance, in C, a float may use two bytes of storage, while a double could use four bytes (or four and eight, respectively). With more bits, you have higher precision. double has approximately twice the precision of a float.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: using MFC VC++ - which is more efficient - float or double?
    ... Float has other nasty implications. ... who keep insisting that binary floating point should behave exactly like decimal numbers. ... instructions can create different performance. ... I'm seeing on the order of 25x faster 32 bit int timing. ...
    (microsoft.public.vc.mfc)
  • Re: Good C Question | pointer problem
    ... int main{ ... This allocates an array of 100 chars and putting the result in ptr. ... This will give you 100/sizeof (float) entries. ... You did not store any floating point values at fpor fp ...
    (comp.programming)
  • Re: static_cast<unsigned int> question...
    ... > unsigned int test2; ... This is caused by the way the float type store number internally. ... floating point value to: ... This is also the reason why comparing two floating point values with the ...
    (comp.lang.cpp)
  • Re: 0.0 versus 0.0f
    ... You said it treats it as a float rather than an int. ... the Microsoft C compiler does not complain about ... integer or floating point. ...
    (microsoft.public.vc.mfc)
  • Re: 0.0 versus 0.0f
    ... The first one adds the two doubles and stores the double result in a float. ... rather than converting them to some higher precision (e.g. ... floating point suffix to an integer literal. ...
    (microsoft.public.vc.mfc)