Jump to content

Archived

This topic is now archived and is closed to further replies.

shan_cool

Exact Value

Recommended Posts

Hi all

I want to add 2 fields in PHP and i don't want the output to be rounded off,I need the exact value,say for eg
Ist field value is 1.23 and
2nd field value is 2.89

I want the output to be 4.12 not 4

can anybody help me
shan

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php
$number1=1.23;
$number2=2.89;
echo $number1 + $number2;
?>[/quote]

That works fine for me :)

Share this post


Link to post
Share on other sites
decimal/float numbers don't get rounded off unless you specify.

[code]
$a = 1.23;
$b = 2.89;

$c = $a+b;
echo $c;

// output is 4.12
[/code]

Share this post


Link to post
Share on other sites
Hi,

Thanks very much for ur reply,I am printing the value in excel so it rounding off by itself,so how can i do this..

Please help

Thnks in Advance,
shan

Share this post


Link to post
Share on other sites
In case you hadn't noticed, this is a PHP forum, NOT M$ Office.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.