note 9309 modified in bcmul by jmcastagnetto

From: Date: Fri, 27 Oct 2000 10:31:49 +0000
Subject: note 9309 modified in bcmul by jmcastagnetto
Groups: php.notes 
Request: Send a blank email to php-notes+get-7058@lists.php.net to get a copy of this message
[Editor's note: It is not that the parameter is not optional, but that when using the bc* functions, you should defined the scale beforehand using bcscale(), e.g. in the example below you should use "bcscale(3);" before you use bcmul/bcdiv/etc.] bcmul optional scale parameter is not optional. Given the following code: echo "A: ".(2900000 / 500)."\n"; echo "C: ".bcdiv( (290000 / 500), 290000, 5). "\n"; echo "K: ".bcmul( bcdiv( (290000 / 500), 290000, 5), 290000,3)."\n"; echo "ACK: ". bcmul( bcdiv( (290000 / 500), 290000, 5), 2900000); Should yield: A: 646.654 C: 0.00200 K: 646.654 ACK: 646 But instead gives: A: 646.654 C: 0.00200 K: 646.654 ACK: 0 Even if there is an integer portion of the result, it will return 0 unless the scale parameter is set to the number of non-zero digits after the decimal. http://www.php.net/manual/function.bcmul.php

« previous php.notes (#7058) next »