2

On my windows box when I run

  $SR = "0";
  $SPR = "149";
  $SR = bcadd($SR, $SPR);
  echo "$SR"; 

It outputs 149.0000000000

But when I upload the same code to my Linux host, the output is 149.

Why?

Positivity
  • 5,406
  • 6
  • 41
  • 61

1 Answers1

3

probably the "scale" is different on the two environments.

Try to set the scale with the bcscale function before doing your operations, For example:

bcscale(3);

$SR = "0";
$SPR = "149";
$SR = bcadd($SR, $SPR);
echo "$SR"; 

Or simply use the third parameter in bcadd to set the scale:

$SR = "0";
$SPR = "149";
$SR = bcadd($SR, $SPR, 3);
echo "$SR"; 
Positivity
  • 5,406
  • 6
  • 41
  • 61
Moppo
  • 18,797
  • 5
  • 65
  • 64