float to integer convertion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • iulian.ilea

    float to integer convertion

    I have this functions, c3 and c2 that computes and return a float
    number. The problem is that wen I pass the result of c2 (float number)
    to c3(), in function apears to be an integer. Ex.:
    $calc2=c2(param s); (float number)
    $calc3=c3($calc 2); ($calc2 - float number)
    echo $calc3; (is not the number that supposed to be, because c4
    computes $calc2 as if it were an integer: if $calc=39.96 it wil be
    converted in 39).

    What is the problem? I really can't see it.

    _____

    function c2($j,$n)
    {
    //=(J54*100)/N47
    $c=$j*100/$n;
    return number_format($ c,2,",",".");
    }

    function c3($calc)
    {
    //=((16*M54)/100)+4
    $c=((16*$calc)/100)+4;
    return number_format($ calc,2,",",".") ;
    }
    ______

  • lorento

    #2
    Re: float to integer convertion

    iulian.ilea wrote:
    function c3($calc)
    {
    //=((16*M54)/100)+4
    $c=((16*$calc)/100)+4;
    return number_format($ calc,2,",",".") ;
    }
    $c=((16*$calc)/100)+4; --$c variable never been used

    return number_format($ calc,2,",",".") ; --it will format the input
    number $calc

    ---



    Comment

    Working...