You are not logged in.
Login
or
Register
.
JsPHP: a JavaScript library providing the PHP API
Home
Register
Demo
Categories
Functions
Contributors
Download
Links
Comments
FAQ
Contact
View
Edit
Test
Benchmark
Revisions
Diff
Developers
Dependencies
Talk
Links
bcadd:
Edit: bcadd
Function:
bcadd
View bcadd
Edit bcadd
Edit code
Edit tests
Edit benchmark
View latest code
Edit latest code
View latest tests
Edit latest tests
Test latest version
Benchmark bcadd
Comment on bcadd
Comment on the latest code
Comment on the latest tests
View revisions
View versions
View tests
Diff versions
View contributors
View dependencies
View comments
View links
Download production code
Download development code
Download latest tests
View the PHP docs
View phpjs.org
View phpjs.org raw code
Description:
Returns the sum of two arbitrary precision numbers.
Edit function
Code
:
function bcadd (left_operand, right_operand, scale) { // discuss at: http://phpjs.org/functions/bcadd/ // original by: lmeyrick (https://sourceforge.net/projects/bcmath-js/) // depends on: _phpjs_shared_bc // example 1: bcadd(1, 2); // returns 1: 3 // todo: implement these testcases var libbcmath = this._phpjs_shared_bc() var first, second, result if (typeof scale === 'undefined') { scale = libbcmath.scale } scale = ((scale < 0) ? 0 : scale) // create objects first = libbcmath.bc_init_num() second = libbcmath.bc_init_num() result = libbcmath.bc_init_num() first = libbcmath.php_str2num(left_operand.toString()) second = libbcmath.php_str2num(right_operand.toString()) result = libbcmath.bc_add(first, second, scale) if (result.n_scale > scale) { result.n_scale = scale } return result.toString() }
You have to be logged in to edit functions.
[
top
]
Comments
There are no comments yet, be the first!
Please
Login
or
Register
to post comments.