Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 14700

Printf vs Sprintf

$
0
0
Boas alguém pode me explicar porque ocorre isto?

    $amt1 = 2.55;
    $amt2 = 3.55;
    $total = $amt1 + $amt2;

    
    echo printf('%.2f',$total); // dá 6.104

   echo sprintf('%.2f',$total); // dá 6.10

Porque razão me dá valores diferentes?

Viewing all articles
Browse latest Browse all 14700

Trending Articles