locutus 2.0.16 → 2.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_util/util.js +13 -13
- package/_util/util.js.map +1 -1
- package/c/math/abs.js.map +1 -1
- package/c/math/frexp.js.map +1 -1
- package/c/stdio/sprintf.js +1 -1
- package/c/stdio/sprintf.js.map +1 -1
- package/golang/strings/Contains.js.map +1 -1
- package/golang/strings/Count.js.map +1 -1
- package/golang/strings/Index2.js.map +1 -1
- package/golang/strings/LastIndex.js.map +1 -1
- package/package.json +62 -59
- package/php/_helpers/_bc.js +2 -3
- package/php/_helpers/_bc.js.map +1 -1
- package/php/_helpers/_phpCastString.js.map +1 -1
- package/php/_helpers/_php_cast_float.js +0 -1
- package/php/_helpers/_php_cast_float.js.map +1 -1
- package/php/_helpers/_php_cast_int.js +0 -1
- package/php/_helpers/_php_cast_int.js.map +1 -1
- package/php/array/array_change_key_case.js +0 -1
- package/php/array/array_change_key_case.js.map +1 -1
- package/php/array/array_chunk.js +6 -5
- package/php/array/array_chunk.js.map +1 -1
- package/php/array/array_column.js +1 -1
- package/php/array/array_column.js.map +1 -1
- package/php/array/array_combine.js +0 -1
- package/php/array/array_combine.js.map +1 -1
- package/php/array/array_count_values.js +0 -1
- package/php/array/array_count_values.js.map +1 -1
- package/php/array/array_diff.js +0 -2
- package/php/array/array_diff.js.map +1 -1
- package/php/array/array_diff_assoc.js +0 -2
- package/php/array/array_diff_assoc.js.map +1 -1
- package/php/array/array_diff_key.js +0 -2
- package/php/array/array_diff_key.js.map +1 -1
- package/php/array/array_diff_uassoc.js +0 -2
- package/php/array/array_diff_uassoc.js.map +1 -1
- package/php/array/array_diff_ukey.js +0 -2
- package/php/array/array_diff_ukey.js.map +1 -1
- package/php/array/array_fill.js +0 -1
- package/php/array/array_fill.js.map +1 -1
- package/php/array/array_fill_keys.js +0 -1
- package/php/array/array_fill_keys.js.map +1 -1
- package/php/array/array_filter.js +0 -1
- package/php/array/array_filter.js.map +1 -1
- package/php/array/array_flip.js +0 -1
- package/php/array/array_flip.js.map +1 -1
- package/php/array/array_intersect.js +0 -3
- package/php/array/array_intersect.js.map +1 -1
- package/php/array/array_intersect_assoc.js +0 -3
- package/php/array/array_intersect_assoc.js.map +1 -1
- package/php/array/array_intersect_key.js +0 -3
- package/php/array/array_intersect_key.js.map +1 -1
- package/php/array/array_intersect_uassoc.js +0 -3
- package/php/array/array_intersect_uassoc.js.map +1 -1
- package/php/array/array_intersect_ukey.js +0 -3
- package/php/array/array_intersect_ukey.js.map +1 -1
- package/php/array/array_key_exists.js +0 -1
- package/php/array/array_key_exists.js.map +1 -1
- package/php/array/array_keys.js +0 -1
- package/php/array/array_keys.js.map +1 -1
- package/php/array/array_map.js +0 -1
- package/php/array/array_map.js.map +1 -1
- package/php/array/array_merge.js +0 -1
- package/php/array/array_merge.js.map +1 -1
- package/php/array/array_merge_recursive.js +0 -1
- package/php/array/array_merge_recursive.js.map +1 -1
- package/php/array/array_multisort.js +0 -1
- package/php/array/array_multisort.js.map +1 -1
- package/php/array/array_pad.js +0 -1
- package/php/array/array_pad.js.map +1 -1
- package/php/array/array_pop.js +0 -1
- package/php/array/array_pop.js.map +1 -1
- package/php/array/array_product.js +0 -1
- package/php/array/array_product.js.map +1 -1
- package/php/array/array_push.js +0 -1
- package/php/array/array_push.js.map +1 -1
- package/php/array/array_rand.js +0 -1
- package/php/array/array_rand.js.map +1 -1
- package/php/array/array_reduce.js +0 -1
- package/php/array/array_reduce.js.map +1 -1
- package/php/array/array_replace.js +0 -1
- package/php/array/array_replace.js.map +1 -1
- package/php/array/array_replace_recursive.js +0 -1
- package/php/array/array_replace_recursive.js.map +1 -1
- package/php/array/array_reverse.js +0 -1
- package/php/array/array_reverse.js.map +1 -1
- package/php/array/array_search.js +1 -2
- package/php/array/array_search.js.map +1 -1
- package/php/array/array_shift.js +0 -1
- package/php/array/array_shift.js.map +1 -1
- package/php/array/array_slice.js +2 -2
- package/php/array/array_slice.js.map +1 -1
- package/php/array/array_splice.js +0 -1
- package/php/array/array_splice.js.map +1 -1
- package/php/array/array_sum.js +0 -1
- package/php/array/array_sum.js.map +1 -1
- package/php/array/array_udiff.js +0 -3
- package/php/array/array_udiff.js.map +1 -1
- package/php/array/array_udiff_assoc.js +0 -2
- package/php/array/array_udiff_assoc.js.map +1 -1
- package/php/array/array_udiff_uassoc.js +0 -2
- package/php/array/array_udiff_uassoc.js.map +1 -1
- package/php/array/array_uintersect.js +0 -3
- package/php/array/array_uintersect.js.map +1 -1
- package/php/array/array_uintersect_uassoc.js +0 -3
- package/php/array/array_uintersect_uassoc.js.map +1 -1
- package/php/array/array_unique.js +0 -1
- package/php/array/array_unique.js.map +1 -1
- package/php/array/array_unshift.js +0 -1
- package/php/array/array_unshift.js.map +1 -1
- package/php/array/array_values.js +0 -1
- package/php/array/array_values.js.map +1 -1
- package/php/array/array_walk.js +0 -1
- package/php/array/array_walk.js.map +1 -1
- package/php/array/array_walk_recursive.js +0 -1
- package/php/array/array_walk_recursive.js.map +1 -1
- package/php/array/arsort.js.map +1 -1
- package/php/array/asort.js.map +1 -1
- package/php/array/count.js.map +1 -1
- package/php/array/current.js.map +1 -1
- package/php/array/each.js.map +1 -1
- package/php/array/end.js.map +1 -1
- package/php/array/in_array.js +1 -2
- package/php/array/in_array.js.map +1 -1
- package/php/array/key.js.map +1 -1
- package/php/array/krsort.js.map +1 -1
- package/php/array/ksort.js.map +1 -1
- package/php/array/natcasesort.js.map +1 -1
- package/php/array/natsort.js.map +1 -1
- package/php/array/next.js.map +1 -1
- package/php/array/pos.js.map +1 -1
- package/php/array/prev.js.map +1 -1
- package/php/array/range.js.map +1 -1
- package/php/array/reset.js.map +1 -1
- package/php/array/rsort.js.map +1 -1
- package/php/array/shuffle.js.map +1 -1
- package/php/array/sizeof.js.map +1 -1
- package/php/array/sort.js.map +1 -1
- package/php/array/uasort.js.map +1 -1
- package/php/array/uksort.js.map +1 -1
- package/php/array/usort.js.map +1 -1
- package/php/bc/bcadd.js.map +1 -1
- package/php/bc/bccomp.js.map +1 -1
- package/php/bc/bcdiv.js.map +1 -1
- package/php/bc/bcmul.js.map +1 -1
- package/php/bc/bcround.js.map +1 -1
- package/php/bc/bcscale.js.map +1 -1
- package/php/bc/bcsub.js.map +1 -1
- package/php/ctype/ctype_alnum.js +0 -1
- package/php/ctype/ctype_alnum.js.map +1 -1
- package/php/ctype/ctype_alpha.js +0 -1
- package/php/ctype/ctype_alpha.js.map +1 -1
- package/php/ctype/ctype_cntrl.js +0 -1
- package/php/ctype/ctype_cntrl.js.map +1 -1
- package/php/ctype/ctype_digit.js +0 -1
- package/php/ctype/ctype_digit.js.map +1 -1
- package/php/ctype/ctype_graph.js +0 -1
- package/php/ctype/ctype_graph.js.map +1 -1
- package/php/ctype/ctype_lower.js +0 -1
- package/php/ctype/ctype_lower.js.map +1 -1
- package/php/ctype/ctype_print.js +0 -1
- package/php/ctype/ctype_print.js.map +1 -1
- package/php/ctype/ctype_punct.js +0 -1
- package/php/ctype/ctype_punct.js.map +1 -1
- package/php/ctype/ctype_space.js +0 -1
- package/php/ctype/ctype_space.js.map +1 -1
- package/php/ctype/ctype_upper.js +0 -1
- package/php/ctype/ctype_upper.js.map +1 -1
- package/php/ctype/ctype_xdigit.js +0 -1
- package/php/ctype/ctype_xdigit.js.map +1 -1
- package/php/datetime/checkdate.js.map +1 -1
- package/php/datetime/date.js +1 -2
- package/php/datetime/date.js.map +1 -1
- package/php/datetime/date_parse.js +0 -1
- package/php/datetime/date_parse.js.map +1 -1
- package/php/datetime/getdate.js +1 -2
- package/php/datetime/getdate.js.map +1 -1
- package/php/datetime/gettimeofday.js.map +1 -1
- package/php/datetime/gmdate.js.map +1 -1
- package/php/datetime/gmmktime.js.map +1 -1
- package/php/datetime/gmstrftime.js.map +1 -1
- package/php/datetime/idate.js.map +1 -1
- package/php/datetime/microtime.js.map +1 -1
- package/php/datetime/mktime.js.map +1 -1
- package/php/datetime/strftime.js.map +1 -1
- package/php/datetime/strptime.js.map +1 -1
- package/php/datetime/strtotime.js +28 -14
- package/php/datetime/strtotime.js.map +1 -1
- package/php/datetime/time.js.map +1 -1
- package/php/exec/escapeshellarg.js +1 -1
- package/php/exec/escapeshellarg.js.map +1 -1
- package/php/filesystem/basename.js.map +1 -1
- package/php/filesystem/dirname.js.map +1 -1
- package/php/filesystem/file_get_contents.js +0 -1
- package/php/filesystem/file_get_contents.js.map +1 -1
- package/php/filesystem/pathinfo.js.map +1 -1
- package/php/filesystem/realpath.js.map +1 -1
- package/php/funchand/call_user_func.js +0 -1
- package/php/funchand/call_user_func.js.map +1 -1
- package/php/funchand/call_user_func_array.js +0 -1
- package/php/funchand/call_user_func_array.js.map +1 -1
- package/php/funchand/create_function.js +0 -1
- package/php/funchand/create_function.js.map +1 -1
- package/php/funchand/function_exists.js +0 -1
- package/php/funchand/function_exists.js.map +1 -1
- package/php/funchand/get_defined_functions.js +0 -1
- package/php/funchand/get_defined_functions.js.map +1 -1
- package/php/i18n/i18n_loc_get_default.js +0 -1
- package/php/i18n/i18n_loc_get_default.js.map +1 -1
- package/php/i18n/i18n_loc_set_default.js +0 -1
- package/php/i18n/i18n_loc_set_default.js.map +1 -1
- package/php/info/assert_options.js +0 -1
- package/php/info/assert_options.js.map +1 -1
- package/php/info/getenv.js.map +1 -1
- package/php/info/ini_get.js +0 -1
- package/php/info/ini_get.js.map +1 -1
- package/php/info/ini_set.js +0 -1
- package/php/info/ini_set.js.map +1 -1
- package/php/info/set_time_limit.js +0 -1
- package/php/info/set_time_limit.js.map +1 -1
- package/php/info/version_compare.js +0 -1
- package/php/info/version_compare.js.map +1 -1
- package/php/json/json_decode.js +0 -1
- package/php/json/json_decode.js.map +1 -1
- package/php/json/json_encode.js +0 -1
- package/php/json/json_encode.js.map +1 -1
- package/php/json/json_last_error.js +0 -1
- package/php/json/json_last_error.js.map +1 -1
- package/php/math/abs.js.map +1 -1
- package/php/math/acos.js.map +1 -1
- package/php/math/acosh.js.map +1 -1
- package/php/math/asin.js.map +1 -1
- package/php/math/asinh.js.map +1 -1
- package/php/math/atan.js.map +1 -1
- package/php/math/atan2.js.map +1 -1
- package/php/math/atanh.js.map +1 -1
- package/php/math/base_convert.js +0 -1
- package/php/math/base_convert.js.map +1 -1
- package/php/math/bindec.js.map +1 -1
- package/php/math/ceil.js.map +1 -1
- package/php/math/cos.js.map +1 -1
- package/php/math/cosh.js.map +1 -1
- package/php/math/decbin.js +1 -1
- package/php/math/decbin.js.map +1 -1
- package/php/math/dechex.js +1 -1
- package/php/math/dechex.js.map +1 -1
- package/php/math/decoct.js +1 -1
- package/php/math/decoct.js.map +1 -1
- package/php/math/deg2rad.js.map +1 -1
- package/php/math/exp.js.map +1 -1
- package/php/math/expm1.js.map +1 -1
- package/php/math/floor.js.map +1 -1
- package/php/math/fmod.js.map +1 -1
- package/php/math/getrandmax.js.map +1 -1
- package/php/math/hexdec.js.map +1 -1
- package/php/math/hypot.js.map +1 -1
- package/php/math/is_finite.js +0 -1
- package/php/math/is_finite.js.map +1 -1
- package/php/math/is_infinite.js +0 -1
- package/php/math/is_infinite.js.map +1 -1
- package/php/math/is_nan.js +0 -1
- package/php/math/is_nan.js.map +1 -1
- package/php/math/lcg_value.js +0 -1
- package/php/math/lcg_value.js.map +1 -1
- package/php/math/log.js.map +1 -1
- package/php/math/log10.js.map +1 -1
- package/php/math/log1p.js.map +1 -1
- package/php/math/max.js.map +1 -1
- package/php/math/min.js.map +1 -1
- package/php/math/mt_getrandmax.js +0 -1
- package/php/math/mt_getrandmax.js.map +1 -1
- package/php/math/mt_rand.js +0 -1
- package/php/math/mt_rand.js.map +1 -1
- package/php/math/octdec.js.map +1 -1
- package/php/math/pi.js.map +1 -1
- package/php/math/pow.js.map +1 -1
- package/php/math/rad2deg.js.map +1 -1
- package/php/math/rand.js.map +1 -1
- package/php/math/round.js.map +1 -1
- package/php/math/sin.js.map +1 -1
- package/php/math/sinh.js.map +1 -1
- package/php/math/sqrt.js.map +1 -1
- package/php/math/tan.js.map +1 -1
- package/php/math/tanh.js.map +1 -1
- package/php/misc/pack.js +15 -15
- package/php/misc/pack.js.map +1 -1
- package/php/misc/uniqid.js.map +1 -1
- package/php/net-gopher/gopher_parsedir.js +0 -1
- package/php/net-gopher/gopher_parsedir.js.map +1 -1
- package/php/network/inet_ntop.js +0 -1
- package/php/network/inet_ntop.js.map +1 -1
- package/php/network/inet_pton.js +1 -2
- package/php/network/inet_pton.js.map +1 -1
- package/php/network/ip2long.js.map +1 -1
- package/php/network/long2ip.js +1 -1
- package/php/network/long2ip.js.map +1 -1
- package/php/network/setcookie.js.map +1 -1
- package/php/network/setrawcookie.js.map +1 -1
- package/php/pcre/preg_match.js +0 -1
- package/php/pcre/preg_match.js.map +1 -1
- package/php/pcre/preg_quote.js +0 -1
- package/php/pcre/preg_quote.js.map +1 -1
- package/php/pcre/preg_replace.js +0 -1
- package/php/pcre/preg_replace.js.map +1 -1
- package/php/pcre/sql_regcase.js +0 -1
- package/php/pcre/sql_regcase.js.map +1 -1
- package/php/strings/addcslashes.js.map +1 -1
- package/php/strings/addslashes.js.map +1 -1
- package/php/strings/bin2hex.js.map +1 -1
- package/php/strings/chop.js.map +1 -1
- package/php/strings/chr.js +2 -2
- package/php/strings/chr.js.map +1 -1
- package/php/strings/chunk_split.js +0 -1
- package/php/strings/chunk_split.js.map +1 -1
- package/php/strings/convert_cyr_string.js +0 -1
- package/php/strings/convert_cyr_string.js.map +1 -1
- package/php/strings/convert_uuencode.js +0 -1
- package/php/strings/convert_uuencode.js.map +1 -1
- package/php/strings/count_chars.js +0 -1
- package/php/strings/count_chars.js.map +1 -1
- package/php/strings/crc32.js +1 -1
- package/php/strings/crc32.js.map +1 -1
- package/php/strings/echo.js.map +1 -1
- package/php/strings/explode.js.map +1 -1
- package/php/strings/get_html_translation_table.js +0 -1
- package/php/strings/get_html_translation_table.js.map +1 -1
- package/php/strings/hex2bin.js.map +1 -1
- package/php/strings/html_entity_decode.js +0 -1
- package/php/strings/html_entity_decode.js.map +1 -1
- package/php/strings/htmlentities.js.map +1 -1
- package/php/strings/htmlspecialchars.js.map +1 -1
- package/php/strings/htmlspecialchars_decode.js +0 -1
- package/php/strings/htmlspecialchars_decode.js.map +1 -1
- package/php/strings/implode.js.map +1 -1
- package/php/strings/join.js.map +1 -1
- package/php/strings/lcfirst.js.map +1 -1
- package/php/strings/levenshtein.js.map +1 -1
- package/php/strings/localeconv.js.map +1 -1
- package/php/strings/ltrim.js.map +1 -1
- package/php/strings/md5.js +67 -67
- package/php/strings/md5.js.map +1 -1
- package/php/strings/md5_file.js +0 -1
- package/php/strings/md5_file.js.map +1 -1
- package/php/strings/metaphone.js +1 -1
- package/php/strings/metaphone.js.map +1 -1
- package/php/strings/money_format.js +0 -1
- package/php/strings/money_format.js.map +1 -1
- package/php/strings/nl2br.js.map +1 -1
- package/php/strings/nl_langinfo.js +0 -1
- package/php/strings/nl_langinfo.js.map +1 -1
- package/php/strings/number_format.js +0 -1
- package/php/strings/number_format.js.map +1 -1
- package/php/strings/ord.js +3 -3
- package/php/strings/ord.js.map +1 -1
- package/php/strings/parse_str.js +0 -1
- package/php/strings/parse_str.js.map +1 -1
- package/php/strings/printf.js.map +1 -1
- package/php/strings/quoted_printable_decode.js +0 -1
- package/php/strings/quoted_printable_decode.js.map +1 -1
- package/php/strings/quoted_printable_encode.js +0 -1
- package/php/strings/quoted_printable_encode.js.map +1 -1
- package/php/strings/quotemeta.js.map +1 -1
- package/php/strings/rtrim.js.map +1 -1
- package/php/strings/setlocale.js.map +1 -1
- package/php/strings/sha1.js +7 -7
- package/php/strings/sha1.js.map +1 -1
- package/php/strings/sha1_file.js +0 -1
- package/php/strings/sha1_file.js.map +1 -1
- package/php/strings/similar_text.js +1 -2
- package/php/strings/similar_text.js.map +1 -1
- package/php/strings/soundex.js.map +1 -1
- package/php/strings/split.js.map +1 -1
- package/php/strings/sprintf.js.map +1 -1
- package/php/strings/sscanf.js.map +1 -1
- package/php/strings/str_getcsv.js +0 -1
- package/php/strings/str_getcsv.js.map +1 -1
- package/php/strings/str_ireplace.js +0 -1
- package/php/strings/str_ireplace.js.map +1 -1
- package/php/strings/str_pad.js +0 -1
- package/php/strings/str_pad.js.map +1 -1
- package/php/strings/str_repeat.js +0 -1
- package/php/strings/str_repeat.js.map +1 -1
- package/php/strings/str_replace.js +0 -1
- package/php/strings/str_replace.js.map +1 -1
- package/php/strings/str_rot13.js +0 -1
- package/php/strings/str_rot13.js.map +1 -1
- package/php/strings/str_shuffle.js +0 -1
- package/php/strings/str_shuffle.js.map +1 -1
- package/php/strings/str_split.js +0 -1
- package/php/strings/str_split.js.map +1 -1
- package/php/strings/str_word_count.js +4 -5
- package/php/strings/str_word_count.js.map +1 -1
- package/php/strings/strcasecmp.js.map +1 -1
- package/php/strings/strchr.js.map +1 -1
- package/php/strings/strcmp.js.map +1 -1
- package/php/strings/strcoll.js.map +1 -1
- package/php/strings/strcspn.js.map +1 -1
- package/php/strings/strip_tags.js +0 -1
- package/php/strings/strip_tags.js.map +1 -1
- package/php/strings/stripos.js.map +1 -1
- package/php/strings/stripslashes.js.map +1 -1
- package/php/strings/stristr.js.map +1 -1
- package/php/strings/strlen.js +4 -4
- package/php/strings/strlen.js.map +1 -1
- package/php/strings/strnatcasecmp.js.map +1 -1
- package/php/strings/strnatcmp.js.map +1 -1
- package/php/strings/strncasecmp.js.map +1 -1
- package/php/strings/strncmp.js.map +1 -1
- package/php/strings/strpbrk.js.map +1 -1
- package/php/strings/strpos.js.map +1 -1
- package/php/strings/strrchr.js.map +1 -1
- package/php/strings/strrev.js.map +1 -1
- package/php/strings/strripos.js.map +1 -1
- package/php/strings/strrpos.js.map +1 -1
- package/php/strings/strspn.js.map +1 -1
- package/php/strings/strstr.js.map +1 -1
- package/php/strings/strtok.js.map +1 -1
- package/php/strings/strtolower.js.map +1 -1
- package/php/strings/strtoupper.js.map +1 -1
- package/php/strings/strtr.js.map +1 -1
- package/php/strings/substr.js.map +1 -1
- package/php/strings/substr_compare.js +0 -1
- package/php/strings/substr_compare.js.map +1 -1
- package/php/strings/substr_count.js +0 -1
- package/php/strings/substr_count.js.map +1 -1
- package/php/strings/substr_replace.js +0 -1
- package/php/strings/substr_replace.js.map +1 -1
- package/php/strings/trim.js.map +1 -1
- package/php/strings/ucfirst.js.map +1 -1
- package/php/strings/ucwords.js.map +1 -1
- package/php/strings/vprintf.js.map +1 -1
- package/php/strings/vsprintf.js.map +1 -1
- package/php/strings/wordwrap.js.map +1 -1
- package/php/url/base64_decode.js +0 -1
- package/php/url/base64_decode.js.map +1 -1
- package/php/url/base64_encode.js +0 -1
- package/php/url/base64_encode.js.map +1 -1
- package/php/url/http_build_query.js +0 -1
- package/php/url/http_build_query.js.map +1 -1
- package/php/url/parse_url.js +0 -1
- package/php/url/parse_url.js.map +1 -1
- package/php/url/rawurldecode.js.map +1 -1
- package/php/url/rawurlencode.js.map +1 -1
- package/php/url/urldecode.js.map +1 -1
- package/php/url/urlencode.js.map +1 -1
- package/php/var/boolval.js.map +1 -1
- package/php/var/doubleval.js.map +1 -1
- package/php/var/empty.js.map +1 -1
- package/php/var/floatval.js.map +1 -1
- package/php/var/gettype.js.map +1 -1
- package/php/var/intval.js.map +1 -1
- package/php/var/is_array.js +0 -1
- package/php/var/is_array.js.map +1 -1
- package/php/var/is_binary.js +0 -1
- package/php/var/is_binary.js.map +1 -1
- package/php/var/is_bool.js +0 -1
- package/php/var/is_bool.js.map +1 -1
- package/php/var/is_buffer.js +0 -1
- package/php/var/is_buffer.js.map +1 -1
- package/php/var/is_callable.js +1 -2
- package/php/var/is_callable.js.map +1 -1
- package/php/var/is_double.js +0 -1
- package/php/var/is_double.js.map +1 -1
- package/php/var/is_float.js +0 -1
- package/php/var/is_float.js.map +1 -1
- package/php/var/is_int.js +0 -1
- package/php/var/is_int.js.map +1 -1
- package/php/var/is_integer.js +0 -1
- package/php/var/is_integer.js.map +1 -1
- package/php/var/is_long.js +0 -1
- package/php/var/is_long.js.map +1 -1
- package/php/var/is_null.js +0 -1
- package/php/var/is_null.js.map +1 -1
- package/php/var/is_numeric.js +0 -1
- package/php/var/is_numeric.js.map +1 -1
- package/php/var/is_object.js +0 -1
- package/php/var/is_object.js.map +1 -1
- package/php/var/is_real.js +0 -1
- package/php/var/is_real.js.map +1 -1
- package/php/var/is_scalar.js +0 -1
- package/php/var/is_scalar.js.map +1 -1
- package/php/var/is_string.js +0 -1
- package/php/var/is_string.js.map +1 -1
- package/php/var/is_unicode.js +0 -1
- package/php/var/is_unicode.js.map +1 -1
- package/php/var/isset.js.map +1 -1
- package/php/var/print_r.js +0 -1
- package/php/var/print_r.js.map +1 -1
- package/php/var/serialize.js.map +1 -1
- package/php/var/strval.js.map +1 -1
- package/php/var/unserialize.js +12 -16
- package/php/var/unserialize.js.map +1 -1
- package/php/var/var_dump.js +0 -1
- package/php/var/var_dump.js.map +1 -1
- package/php/var/var_export.js +0 -1
- package/php/var/var_export.js.map +1 -1
- package/php/xdiff/xdiff_string_diff.js +0 -1
- package/php/xdiff/xdiff_string_diff.js.map +1 -1
- package/php/xdiff/xdiff_string_patch.js +0 -1
- package/php/xdiff/xdiff_string_patch.js.map +1 -1
- package/php/xml/utf8_decode.js +10 -11
- package/php/xml/utf8_decode.js.map +1 -1
- package/php/xml/utf8_encode.js +4 -5
- package/php/xml/utf8_encode.js.map +1 -1
- package/python/string/ascii_letters.js +0 -1
- package/python/string/ascii_letters.js.map +1 -1
- package/python/string/ascii_lowercase.js +0 -1
- package/python/string/ascii_lowercase.js.map +1 -1
- package/python/string/ascii_uppercase.js +0 -1
- package/python/string/ascii_uppercase.js.map +1 -1
- package/python/string/capwords.js.map +1 -1
- package/python/string/index.js +1 -0
- package/python/string/index.js.map +1 -1
- package/python/string/punctuation.js +2 -2
- package/python/string/punctuation.js.map +1 -1
- package/ruby/Math/acos.js.map +1 -1
- package/php/_locutus_shared/_locutus_shared_bc.js +0 -1255
- package/php/_locutus_shared/_locutus_shared_bc.js.map +0 -1
- package/php/_locutus_shared/index.js +0 -4
- package/php/_locutus_shared/index.js.map +0 -1
|
@@ -1,1255 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = function _bc() {
|
|
4
|
-
// eslint-disable-line camelcase
|
|
5
|
-
// discuss at: http://locutus.io
|
|
6
|
-
/php/_helpers/_bc
|
|
7
|
-
// original by: lmeyrick (https://sourceforge.net/projects/bcmath-js/)
|
|
8
|
-
// improved by: Brett Zamir (http://brett-zamir.me)
|
|
9
|
-
// example 1: var $bc = _bc()
|
|
10
|
-
// example 1: var $result = $bc.PLUS
|
|
11
|
-
// returns 1: '+'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* BC Math Library for Javascript
|
|
15
|
-
* Ported from the PHP5 bcmath extension source code,
|
|
16
|
-
* which uses the Libbcmath package...
|
|
17
|
-
* Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
|
|
18
|
-
* Copyright (C) 2000 Philip A. Nelson
|
|
19
|
-
* The Free Software Foundation, Inc.
|
|
20
|
-
* 59 Temple Place, Suite 330
|
|
21
|
-
* Boston, MA 02111-1307 USA.
|
|
22
|
-
* e-mail: philnelson@acm.org
|
|
23
|
-
* us-mail: Philip A. Nelson
|
|
24
|
-
* Computer Science Department, 9062
|
|
25
|
-
* Western Washington University
|
|
26
|
-
* Bellingham, WA 98226-9062
|
|
27
|
-
*
|
|
28
|
-
* bcmath-js homepage:
|
|
29
|
-
*
|
|
30
|
-
* This code is covered under the LGPL licence, and can be used however you want :)
|
|
31
|
-
* Be kind and share any decent code changes.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Binary Calculator (BC) Arbitrary Precision Mathematics Lib v0.10 (LGPL)
|
|
36
|
-
* Copy of Libbcmath included in PHP5 src
|
|
37
|
-
*
|
|
38
|
-
* Note: this is just the shared library file and does not include the php-style functions.
|
|
39
|
-
* use bcmath{-min}.js for functions like bcadd, bcsub etc.
|
|
40
|
-
*
|
|
41
|
-
* Feel free to use how-ever you want, just email any bug-fixes/improvements
|
|
42
|
-
* to the sourceforge project:
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* Ported from the PHP5 bcmath extension source code,
|
|
46
|
-
* which uses the Libbcmath package...
|
|
47
|
-
* Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
|
|
48
|
-
* Copyright (C) 2000 Philip A. Nelson
|
|
49
|
-
* The Free Software Foundation, Inc.
|
|
50
|
-
* 59 Temple Place, Suite 330
|
|
51
|
-
* Boston, MA 02111-1307 USA.
|
|
52
|
-
* e-mail: philnelson@acm.org
|
|
53
|
-
* us-mail: Philip A. Nelson
|
|
54
|
-
* Computer Science Department, 9062
|
|
55
|
-
* Western Washington University
|
|
56
|
-
* Bellingham, WA 98226-9062
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
var Libbcmath = {
|
|
60
|
-
PLUS: '+',
|
|
61
|
-
MINUS: '-',
|
|
62
|
-
BASE: 10,
|
|
63
|
-
// must be 10 (for now)
|
|
64
|
-
scale: 0,
|
|
65
|
-
// default scale
|
|
66
|
-
/**
|
|
67
|
-
* Basic number structure
|
|
68
|
-
*/
|
|
69
|
-
bc_num: function bc_num() {
|
|
70
|
-
this.n_sign = null; // sign
|
|
71
|
-
this.n_len = null; // (int) The number of digits before the decimal point.
|
|
72
|
-
this.n_scale = null; // (int) The number of digits after the decimal point.
|
|
73
|
-
// this.n_refs = null; // (int) The number of pointers to this number.
|
|
74
|
-
// this.n_text = null; // ?? Linked list for available list.
|
|
75
|
-
this.n_value = null; // array as value, where 1.23 = [1,2,3]
|
|
76
|
-
this.toString = function () {
|
|
77
|
-
var r, tmp;
|
|
78
|
-
tmp = this.n_value.join('');
|
|
79
|
-
|
|
80
|
-
// add minus sign (if applicable) then add the integer part
|
|
81
|
-
r = (this.n_sign === Libbcmath.PLUS ? '' : this.n_sign) + tmp.substr(0, this.n_len);
|
|
82
|
-
|
|
83
|
-
// if decimal places, add a . and the decimal part
|
|
84
|
-
if (this.n_scale > 0) {
|
|
85
|
-
r += '.' + tmp.substr(this.n_len, this.n_scale);
|
|
86
|
-
}
|
|
87
|
-
return r;
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Base add function
|
|
93
|
-
*
|
|
94
|
-
// Here is the full add routine that takes care of negative numbers.
|
|
95
|
-
// N1 is added to N2 and the result placed into RESULT. SCALE_MIN
|
|
96
|
-
// is the minimum scale for the result.
|
|
97
|
-
*
|
|
98
|
-
* @param {bc_num} n1
|
|
99
|
-
* @param {bc_num} n2
|
|
100
|
-
* @param {int} scaleMin
|
|
101
|
-
* @return bc_num
|
|
102
|
-
*/
|
|
103
|
-
bc_add: function bc_add(n1, n2, scaleMin) {
|
|
104
|
-
var sum, cmpRes, resScale;
|
|
105
|
-
|
|
106
|
-
if (n1.n_sign === n2.n_sign) {
|
|
107
|
-
sum = Libbcmath._bc_do_add(n1, n2, scaleMin);
|
|
108
|
-
sum.n_sign = n1.n_sign;
|
|
109
|
-
} else {
|
|
110
|
-
// subtraction must be done.
|
|
111
|
-
cmpRes = Libbcmath._bc_do_compare(n1, n2, false, false); // Compare magnitudes.
|
|
112
|
-
switch (cmpRes) {
|
|
113
|
-
case -1:
|
|
114
|
-
// n1 is less than n2, subtract n1 from n2.
|
|
115
|
-
sum = Libbcmath._bc_do_sub(n2, n1, scaleMin);
|
|
116
|
-
sum.n_sign = n2.n_sign;
|
|
117
|
-
break;
|
|
118
|
-
|
|
119
|
-
case 0:
|
|
120
|
-
// They are equal! return zero with the correct scale!
|
|
121
|
-
resScale = Libbcmath.MAX(scaleMin, Libbcmath.MAX(n1.n_scale, n2.n_scale));
|
|
122
|
-
sum = Libbcmath.bc_new_num(1, resScale);
|
|
123
|
-
Libbcmath.memset(sum.n_value, 0, 0, resScale + 1);
|
|
124
|
-
break;
|
|
125
|
-
|
|
126
|
-
case 1:
|
|
127
|
-
// n2 is less than n1, subtract n2 from n1.
|
|
128
|
-
sum = Libbcmath._bc_do_sub(n1, n2, scaleMin);
|
|
129
|
-
sum.n_sign = n1.n_sign;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return sum;
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* This is the "user callable" routine to compare numbers N1 and N2.
|
|
137
|
-
* @param {bc_num} n1
|
|
138
|
-
* @param {bc_num} n2
|
|
139
|
-
* @return int -1, 0, 1 (n1 < n2, ===, n1 > n2)
|
|
140
|
-
*/
|
|
141
|
-
bc_compare: function bc_compare(n1, n2) {
|
|
142
|
-
return Libbcmath._bc_do_compare(n1, n2, true, false);
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
_one_mult: function _one_mult(num, nPtr, size, digit, result, rPtr) {
|
|
146
|
-
var carry, value; // int
|
|
147
|
-
var nptr, rptr; // int pointers
|
|
148
|
-
if (digit === 0) {
|
|
149
|
-
Libbcmath.memset(result, 0, 0, size); // memset (result, 0, size);
|
|
150
|
-
} else {
|
|
151
|
-
if (digit === 1) {
|
|
152
|
-
Libbcmath.memcpy(result, rPtr, num, nPtr, size); // memcpy (result, num, size);
|
|
153
|
-
} else {
|
|
154
|
-
// Initialize
|
|
155
|
-
nptr = nPtr + size - 1; // nptr = (unsigned char *) (num+size-1);
|
|
156
|
-
rptr = rPtr + size - 1; // rptr = (unsigned char *) (result+size-1);
|
|
157
|
-
carry = 0;
|
|
158
|
-
|
|
159
|
-
while (size-- > 0) {
|
|
160
|
-
value = num[nptr--] * digit + carry; // value = *nptr-- * digit + carry;
|
|
161
|
-
result[rptr--] = value % Libbcmath.BASE; // @CHECK cint //*rptr-- = value % BASE;
|
|
162
|
-
carry = Math.floor(value / Libbcmath.BASE); // @CHECK cint //carry = value / BASE;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (carry !== 0) {
|
|
166
|
-
result[rptr] = carry;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
bc_divide: function bc_divide(n1, n2, scale) {
|
|
173
|
-
// var quot // bc_num return
|
|
174
|
-
var qval; // bc_num
|
|
175
|
-
var num1, num2; // string
|
|
176
|
-
var ptr1, ptr2, n2ptr, qptr; // int pointers
|
|
177
|
-
var scale1, val; // int
|
|
178
|
-
var len1, len2, scale2, qdigits, extra, count; // int
|
|
179
|
-
var qdig, qguess, borrow, carry; // int
|
|
180
|
-
var mval; // string
|
|
181
|
-
var zero; // char
|
|
182
|
-
var norm; // int
|
|
183
|
-
// var ptrs // return object from one_mul
|
|
184
|
-
// Test for divide by zero. (return failure)
|
|
185
|
-
if (Libbcmath.bc_is_zero(n2)) {
|
|
186
|
-
return -1;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Test for zero divide by anything (return zero)
|
|
190
|
-
if (Libbcmath.bc_is_zero(n1)) {
|
|
191
|
-
return Libbcmath.bc_new_num(1, scale);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/* Test for n1 equals n2 (return 1 as n1 nor n2 are zero)
|
|
195
|
-
if (Libbcmath.bc_compare(n1, n2, Libbcmath.MAX(n1.n_scale, n2.n_scale)) === 0) {
|
|
196
|
-
quot=Libbcmath.bc_new_num(1, scale);
|
|
197
|
-
quot.n_value[0] = 1;
|
|
198
|
-
return quot;
|
|
199
|
-
}
|
|
200
|
-
*/
|
|
201
|
-
|
|
202
|
-
// Test for divide by 1. If it is we must truncate.
|
|
203
|
-
// @todo: check where scale > 0 too.. can't see why not
|
|
204
|
-
// (ie bc_is_zero - add bc_is_one function)
|
|
205
|
-
if (n2.n_scale === 0) {
|
|
206
|
-
if (n2.n_len === 1 && n2.n_value[0] === 1) {
|
|
207
|
-
qval = Libbcmath.bc_new_num(n1.n_len, scale); // qval = bc_new_num (n1->n_len, scale);
|
|
208
|
-
qval.n_sign = n1.n_sign === n2.n_sign ? Libbcmath.PLUS : Libbcmath.MINUS;
|
|
209
|
-
// memset (&qval->n_value[n1->n_len],0,scale):
|
|
210
|
-
Libbcmath.memset(qval.n_value, n1.n_len, 0, scale);
|
|
211
|
-
// memcpy (qval->n_value, n1->n_value, n1->n_len + MIN(n1->n_scale,scale)):
|
|
212
|
-
Libbcmath.memcpy(qval.n_value, 0, n1.n_value, 0, n1.n_len + Libbcmath.MIN(n1.n_scale, scale));
|
|
213
|
-
// can we return here? not in c src, but can't see why-not.
|
|
214
|
-
// return qval;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/* Set up the divide. Move the decimal point on n1 by n2's scale.
|
|
219
|
-
Remember, zeros on the end of num2 are wasted effort for dividing. */
|
|
220
|
-
scale2 = n2.n_scale; // scale2 = n2->n_scale;
|
|
221
|
-
n2ptr = n2.n_len + scale2 - 1; // n2ptr = (unsigned char *) n2.n_value+n2.n_len+scale2-1;
|
|
222
|
-
while (scale2 > 0 && n2.n_value[n2ptr--] === 0) {
|
|
223
|
-
scale2--;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
len1 = n1.n_len + scale2;
|
|
227
|
-
scale1 = n1.n_scale - scale2;
|
|
228
|
-
if (scale1 < scale) {
|
|
229
|
-
extra = scale - scale1;
|
|
230
|
-
} else {
|
|
231
|
-
extra = 0;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// num1 = (unsigned char *) safe_emalloc (1, n1.n_len+n1.n_scale, extra+2):
|
|
235
|
-
num1 = Libbcmath.safe_emalloc(1, n1.n_len + n1.n_scale, extra + 2);
|
|
236
|
-
if (num1 === null) {
|
|
237
|
-
Libbcmath.bc_out_of_memory();
|
|
238
|
-
}
|
|
239
|
-
// memset (num1, 0, n1->n_len+n1->n_scale+extra+2):
|
|
240
|
-
Libbcmath.memset(num1, 0, 0, n1.n_len + n1.n_scale + extra + 2);
|
|
241
|
-
// memcpy (num1+1, n1.n_value, n1.n_len+n1.n_scale):
|
|
242
|
-
Libbcmath.memcpy(num1, 1, n1.n_value, 0, n1.n_len + n1.n_scale);
|
|
243
|
-
// len2 = n2->n_len + scale2:
|
|
244
|
-
len2 = n2.n_len + scale2;
|
|
245
|
-
// num2 = (unsigned char *) safe_emalloc (1, len2, 1):
|
|
246
|
-
num2 = Libbcmath.safe_emalloc(1, len2, 1);
|
|
247
|
-
if (num2 === null) {
|
|
248
|
-
Libbcmath.bc_out_of_memory();
|
|
249
|
-
}
|
|
250
|
-
// memcpy (num2, n2.n_value, len2):
|
|
251
|
-
Libbcmath.memcpy(num2, 0, n2.n_value, 0, len2);
|
|
252
|
-
// *(num2+len2) = 0:
|
|
253
|
-
num2[len2] = 0;
|
|
254
|
-
// n2ptr = num2:
|
|
255
|
-
n2ptr = 0;
|
|
256
|
-
// while (*n2ptr === 0):
|
|
257
|
-
while (num2[n2ptr] === 0) {
|
|
258
|
-
n2ptr++;
|
|
259
|
-
len2--;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Calculate the number of quotient digits.
|
|
263
|
-
if (len2 > len1 + scale) {
|
|
264
|
-
qdigits = scale + 1;
|
|
265
|
-
zero = true;
|
|
266
|
-
} else {
|
|
267
|
-
zero = false;
|
|
268
|
-
if (len2 > len1) {
|
|
269
|
-
qdigits = scale + 1; // One for the zero integer part.
|
|
270
|
-
} else {
|
|
271
|
-
qdigits = len1 - len2 + scale + 1;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Allocate and zero the storage for the quotient.
|
|
276
|
-
// qval = bc_new_num (qdigits-scale,scale);
|
|
277
|
-
qval = Libbcmath.bc_new_num(qdigits - scale, scale);
|
|
278
|
-
// memset (qval->n_value, 0, qdigits);
|
|
279
|
-
Libbcmath.memset(qval.n_value, 0, 0, qdigits);
|
|
280
|
-
// Allocate storage for the temporary storage mval.
|
|
281
|
-
// mval = (unsigned char *) safe_emalloc (1, len2, 1);
|
|
282
|
-
mval = Libbcmath.safe_emalloc(1, len2, 1);
|
|
283
|
-
if (mval === null) {
|
|
284
|
-
Libbcmath.bc_out_of_memory();
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Now for the full divide algorithm.
|
|
288
|
-
if (!zero) {
|
|
289
|
-
// Normalize
|
|
290
|
-
// norm = Libbcmath.cint(10 / (Libbcmath.cint(n2.n_value[n2ptr]) + 1));
|
|
291
|
-
// norm = 10 / ((int)*n2ptr + 1)
|
|
292
|
-
norm = Math.floor(10 / (n2.n_value[n2ptr] + 1)); // norm = 10 / ((int)*n2ptr + 1);
|
|
293
|
-
if (norm !== 1) {
|
|
294
|
-
// Libbcmath._one_mult(num1, len1+scale1+extra+1, norm, num1);
|
|
295
|
-
Libbcmath._one_mult(num1, 0, len1 + scale1 + extra + 1, norm, num1, 0);
|
|
296
|
-
// Libbcmath._one_mult(n2ptr, len2, norm, n2ptr);
|
|
297
|
-
Libbcmath._one_mult(n2.n_value, n2ptr, len2, norm, n2.n_value, n2ptr);
|
|
298
|
-
// @todo: Check: Is the pointer affected by the call? if so,
|
|
299
|
-
// maybe need to adjust points on return?
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// Initialize divide loop.
|
|
303
|
-
qdig = 0;
|
|
304
|
-
if (len2 > len1) {
|
|
305
|
-
qptr = len2 - len1; // qptr = (unsigned char *) qval.n_value+len2-len1;
|
|
306
|
-
} else {
|
|
307
|
-
qptr = 0; // qptr = (unsigned char *) qval.n_value;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// Loop
|
|
311
|
-
while (qdig <= len1 + scale - len2) {
|
|
312
|
-
// Calculate the quotient digit guess.
|
|
313
|
-
if (n2.n_value[n2ptr] === num1[qdig]) {
|
|
314
|
-
qguess = 9;
|
|
315
|
-
} else {
|
|
316
|
-
qguess = Math.floor((num1[qdig] * 10 + num1[qdig + 1]) / n2.n_value[n2ptr]);
|
|
317
|
-
}
|
|
318
|
-
// Test qguess.
|
|
319
|
-
|
|
320
|
-
if (n2.n_value[n2ptr + 1] * qguess > (num1[qdig] * 10 + num1[qdig + 1] - n2.n_value[n2ptr] * qguess) * 10 + num1[qdig + 2]) {
|
|
321
|
-
qguess--;
|
|
322
|
-
// And again.
|
|
323
|
-
if (n2.n_value[n2ptr + 1] * qguess > (num1[qdig] * 10 + num1[qdig + 1] - n2.n_value[n2ptr] * qguess) * 10 + num1[qdig + 2]) {
|
|
324
|
-
qguess--;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// Multiply and subtract.
|
|
329
|
-
borrow = 0;
|
|
330
|
-
if (qguess !== 0) {
|
|
331
|
-
mval[0] = 0; //* mval = 0; // @CHECK is this to fix ptr2 < 0?
|
|
332
|
-
// _one_mult (n2ptr, len2, qguess, mval+1); // @CHECK
|
|
333
|
-
Libbcmath._one_mult(n2.n_value, n2ptr, len2, qguess, mval, 1);
|
|
334
|
-
ptr1 = qdig + len2; // (unsigned char *) num1+qdig+len2;
|
|
335
|
-
ptr2 = len2; // (unsigned char *) mval+len2;
|
|
336
|
-
// @todo: CHECK: Does a negative pointer return null?
|
|
337
|
-
// ptr2 can be < 0 here as ptr1 = len2, thus count < len2+1 will always fail ?
|
|
338
|
-
for (count = 0; count < len2 + 1; count++) {
|
|
339
|
-
if (ptr2 < 0) {
|
|
340
|
-
// val = Libbcmath.cint(num1[ptr1]) - 0 - borrow;
|
|
341
|
-
// val = (int) *ptr1 - (int) *ptr2-- - borrow;
|
|
342
|
-
val = num1[ptr1] - 0 - borrow; // val = (int) *ptr1 - (int) *ptr2-- - borrow;
|
|
343
|
-
} else {
|
|
344
|
-
// val = Libbcmath.cint(num1[ptr1]) - Libbcmath.cint(mval[ptr2--]) - borrow;
|
|
345
|
-
// val = (int) *ptr1 - (int) *ptr2-- - borrow;
|
|
346
|
-
// val = (int) *ptr1 - (int) *ptr2-- - borrow;
|
|
347
|
-
val = num1[ptr1] - mval[ptr2--] - borrow;
|
|
348
|
-
}
|
|
349
|
-
if (val < 0) {
|
|
350
|
-
val += 10;
|
|
351
|
-
borrow = 1;
|
|
352
|
-
} else {
|
|
353
|
-
borrow = 0;
|
|
354
|
-
}
|
|
355
|
-
num1[ptr1--] = val;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// Test for negative result.
|
|
360
|
-
if (borrow === 1) {
|
|
361
|
-
qguess--;
|
|
362
|
-
ptr1 = qdig + len2; // (unsigned char *) num1+qdig+len2;
|
|
363
|
-
ptr2 = len2 - 1; // (unsigned char *) n2ptr+len2-1;
|
|
364
|
-
carry = 0;
|
|
365
|
-
for (count = 0; count < len2; count++) {
|
|
366
|
-
if (ptr2 < 0) {
|
|
367
|
-
// val = Libbcmath.cint(num1[ptr1]) + 0 + carry;
|
|
368
|
-
// val = (int) *ptr1 + (int) *ptr2-- + carry;
|
|
369
|
-
// val = (int) *ptr1 + (int) *ptr2-- + carry;
|
|
370
|
-
val = num1[ptr1] + 0 + carry;
|
|
371
|
-
} else {
|
|
372
|
-
// val = Libbcmath.cint(num1[ptr1]) + Libbcmath.cint(n2.n_value[ptr2--]) + carry;
|
|
373
|
-
// val = (int) *ptr1 + (int) *ptr2-- + carry;
|
|
374
|
-
// val = (int) *ptr1 + (int) *ptr2-- + carry;
|
|
375
|
-
val = num1[ptr1] + n2.n_value[ptr2--] + carry;
|
|
376
|
-
}
|
|
377
|
-
if (val > 9) {
|
|
378
|
-
val -= 10;
|
|
379
|
-
carry = 1;
|
|
380
|
-
} else {
|
|
381
|
-
carry = 0;
|
|
382
|
-
}
|
|
383
|
-
num1[ptr1--] = val; //* ptr1-- = val;
|
|
384
|
-
}
|
|
385
|
-
if (carry === 1) {
|
|
386
|
-
// num1[ptr1] = Libbcmath.cint((num1[ptr1] + 1) % 10);
|
|
387
|
-
// *ptr1 = (*ptr1 + 1) % 10; // @CHECK
|
|
388
|
-
// *ptr1 = (*ptr1 + 1) % 10; // @CHECK
|
|
389
|
-
num1[ptr1] = (num1[ptr1] + 1) % 10;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// We now know the quotient digit.
|
|
394
|
-
qval.n_value[qptr++] = qguess; //* qptr++ = qguess;
|
|
395
|
-
qdig++;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// Clean up and return the number.
|
|
400
|
-
qval.n_sign = n1.n_sign === n2.n_sign ? Libbcmath.PLUS : Libbcmath.MINUS;
|
|
401
|
-
if (Libbcmath.bc_is_zero(qval)) {
|
|
402
|
-
qval.n_sign = Libbcmath.PLUS;
|
|
403
|
-
}
|
|
404
|
-
Libbcmath._bc_rm_leading_zeros(qval);
|
|
405
|
-
|
|
406
|
-
return qval;
|
|
407
|
-
|
|
408
|
-
// return 0; // Everything is OK.
|
|
409
|
-
},
|
|
410
|
-
|
|
411
|
-
MUL_BASE_DIGITS: 80,
|
|
412
|
-
MUL_SMALL_DIGITS: 80 / 4,
|
|
413
|
-
// #define MUL_SMALL_DIGITS mul_base_digits/4
|
|
414
|
-
|
|
415
|
-
/* The multiply routine. N2 times N1 is put int PROD with the scale of
|
|
416
|
-
the result being MIN(N2 scale+N1 scale, MAX (SCALE, N2 scale, N1 scale)).
|
|
417
|
-
*/
|
|
418
|
-
/**
|
|
419
|
-
* @param n1 bc_num
|
|
420
|
-
* @param n2 bc_num
|
|
421
|
-
* @param scale [int] optional
|
|
422
|
-
*/
|
|
423
|
-
bc_multiply: function bc_multiply(n1, n2, scale) {
|
|
424
|
-
var pval; // bc_num
|
|
425
|
-
var len1, len2; // int
|
|
426
|
-
var fullScale, prodScale; // int
|
|
427
|
-
// Initialize things.
|
|
428
|
-
len1 = n1.n_len + n1.n_scale;
|
|
429
|
-
len2 = n2.n_len + n2.n_scale;
|
|
430
|
-
fullScale = n1.n_scale + n2.n_scale;
|
|
431
|
-
prodScale = Libbcmath.MIN(fullScale, Libbcmath.MAX(scale, Libbcmath.MAX(n1.n_scale, n2.n_scale)));
|
|
432
|
-
|
|
433
|
-
// pval = Libbcmath.bc_init_num(); // allow pass by ref
|
|
434
|
-
// Do the multiply
|
|
435
|
-
pval = Libbcmath._bc_rec_mul(n1, len1, n2, len2, fullScale);
|
|
436
|
-
|
|
437
|
-
// Assign to prod and clean up the number.
|
|
438
|
-
pval.n_sign = n1.n_sign === n2.n_sign ? Libbcmath.PLUS : Libbcmath.MINUS;
|
|
439
|
-
// pval.n_value = pval.nPtr; // @todo: pval.n_len = len2 + len1 + 1 - fullScale
|
|
440
|
-
pval.n_scale = prodScale;
|
|
441
|
-
Libbcmath._bc_rm_leading_zeros(pval);
|
|
442
|
-
if (Libbcmath.bc_is_zero(pval)) {
|
|
443
|
-
pval.n_sign = Libbcmath.PLUS;
|
|
444
|
-
}
|
|
445
|
-
// bc_free_num (prod);
|
|
446
|
-
return pval;
|
|
447
|
-
},
|
|
448
|
-
|
|
449
|
-
new_sub_num: function new_sub_num(length, scale, value) {
|
|
450
|
-
var temp = new Libbcmath.bc_num(); // eslint-disable-line new-cap
|
|
451
|
-
temp.n_sign = Libbcmath.PLUS;
|
|
452
|
-
temp.n_len = length;
|
|
453
|
-
temp.n_scale = scale;
|
|
454
|
-
temp.n_value = value;
|
|
455
|
-
return temp;
|
|
456
|
-
},
|
|
457
|
-
|
|
458
|
-
_bc_simp_mul: function _bc_simp_mul(n1, n1len, n2, n2len, fullScale) {
|
|
459
|
-
var prod; // bc_num
|
|
460
|
-
var n1ptr, n2ptr, pvptr; // char *n1ptr, *n2ptr, *pvptr;
|
|
461
|
-
var n1end, n2end; // char *n1end, *n2end; // To the end of n1 and n2.
|
|
462
|
-
var indx, sum, prodlen; // int indx, sum, prodlen;
|
|
463
|
-
prodlen = n1len + n2len + 1;
|
|
464
|
-
|
|
465
|
-
prod = Libbcmath.bc_new_num(prodlen, 0);
|
|
466
|
-
|
|
467
|
-
n1end = n1len - 1; // (char *) (n1->n_value + n1len - 1);
|
|
468
|
-
n2end = n2len - 1; // (char *) (n2->n_value + n2len - 1);
|
|
469
|
-
pvptr = prodlen - 1; // (char *) ((*prod)->n_value + prodlen - 1);
|
|
470
|
-
sum = 0;
|
|
471
|
-
|
|
472
|
-
// Here is the loop...
|
|
473
|
-
for (indx = 0; indx < prodlen - 1; indx++) {
|
|
474
|
-
// (char *) (n1end - MAX(0, indx-n2len+1));
|
|
475
|
-
n1ptr = n1end - Libbcmath.MAX(0, indx - n2len + 1);
|
|
476
|
-
// (char *) (n2end - MIN(indx, n2len-1));
|
|
477
|
-
n2ptr = n2end - Libbcmath.MIN(indx, n2len - 1);
|
|
478
|
-
while (n1ptr >= 0 && n2ptr <= n2end) {
|
|
479
|
-
// sum += *n1ptr-- * *n2ptr++;
|
|
480
|
-
sum += n1.n_value[n1ptr--] * n2.n_value[n2ptr++];
|
|
481
|
-
}
|
|
482
|
-
//* pvptr-- = sum % BASE;
|
|
483
|
-
prod.n_value[pvptr--] = Math.floor(sum % Libbcmath.BASE);
|
|
484
|
-
sum = Math.floor(sum / Libbcmath.BASE); // sum = sum / BASE;
|
|
485
|
-
}
|
|
486
|
-
prod.n_value[pvptr] = sum; //* pvptr = sum;
|
|
487
|
-
return prod;
|
|
488
|
-
},
|
|
489
|
-
|
|
490
|
-
/* A special adder/subtractor for the recursive divide and conquer
|
|
491
|
-
multiply algorithm. Note: if sub is called, accum must
|
|
492
|
-
be larger that what is being subtracted. Also, accum and val
|
|
493
|
-
must have n_scale = 0. (e.g. they must look like integers. *) */
|
|
494
|
-
_bc_shift_addsub: function _bc_shift_addsub(accum, val, shift, sub) {
|
|
495
|
-
var accp, valp; // signed char *accp, *valp;
|
|
496
|
-
var count, carry; // int count, carry;
|
|
497
|
-
count = val.n_len;
|
|
498
|
-
if (val.n_value[0] === 0) {
|
|
499
|
-
count--;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
// assert (accum->n_len+accum->n_scale >= shift+count);
|
|
503
|
-
if (accum.n_len + accum.n_scale < shift + count) {
|
|
504
|
-
throw new Error('len + scale < shift + count'); // ?? I think that's what assert does :)
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// Set up pointers and others
|
|
508
|
-
// (signed char *)(accum->n_value + accum->n_len + accum->n_scale - shift - 1);
|
|
509
|
-
accp = accum.n_len + accum.n_scale - shift - 1;
|
|
510
|
-
valp = val.n_len = 1; // (signed char *)(val->n_value + val->n_len - 1);
|
|
511
|
-
carry = 0;
|
|
512
|
-
if (sub) {
|
|
513
|
-
// Subtraction, carry is really borrow.
|
|
514
|
-
while (count--) {
|
|
515
|
-
accum.n_value[accp] -= val.n_value[valp--] + carry; //* accp -= *valp-- + carry;
|
|
516
|
-
if (accum.n_value[accp] < 0) {
|
|
517
|
-
// if (*accp < 0)
|
|
518
|
-
carry = 1;
|
|
519
|
-
accum.n_value[accp--] += Libbcmath.BASE; //* accp-- += BASE;
|
|
520
|
-
} else {
|
|
521
|
-
carry = 0;
|
|
522
|
-
accp--;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
while (carry) {
|
|
526
|
-
accum.n_value[accp] -= carry; //* accp -= carry;
|
|
527
|
-
if (accum.n_value[accp] < 0) {
|
|
528
|
-
// if (*accp < 0)
|
|
529
|
-
accum.n_value[accp--] += Libbcmath.BASE; // *accp-- += BASE;
|
|
530
|
-
} else {
|
|
531
|
-
carry = 0;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
} else {
|
|
535
|
-
// Addition
|
|
536
|
-
while (count--) {
|
|
537
|
-
accum.n_value[accp] += val.n_value[valp--] + carry; //* accp += *valp-- + carry;
|
|
538
|
-
if (accum.n_value[accp] > Libbcmath.BASE - 1) {
|
|
539
|
-
// if (*accp > (BASE-1))
|
|
540
|
-
carry = 1;
|
|
541
|
-
accum.n_value[accp--] -= Libbcmath.BASE; //* accp-- -= BASE;
|
|
542
|
-
} else {
|
|
543
|
-
carry = 0;
|
|
544
|
-
accp--;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
while (carry) {
|
|
548
|
-
accum.n_value[accp] += carry; //* accp += carry;
|
|
549
|
-
if (accum.n_value[accp] > Libbcmath.BASE - 1) {
|
|
550
|
-
// if (*accp > (BASE-1))
|
|
551
|
-
accum.n_value[accp--] -= Libbcmath.BASE; //* accp-- -= BASE;
|
|
552
|
-
} else {
|
|
553
|
-
carry = 0;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return true; // accum is the pass-by-reference return
|
|
558
|
-
},
|
|
559
|
-
|
|
560
|
-
/* Recursive divide and conquer multiply algorithm.
|
|
561
|
-
based on
|
|
562
|
-
Let u = u0 + u1*(b^n)
|
|
563
|
-
Let v = v0 + v1*(b^n)
|
|
564
|
-
Then uv = (B^2n+B^n)*u1*v1 + B^n*(u1-u0)*(v0-v1) + (B^n+1)*u0*v0
|
|
565
|
-
B is the base of storage, number of digits in u1,u0 close to equal.
|
|
566
|
-
*/
|
|
567
|
-
_bc_rec_mul: function _bc_rec_mul(u, ulen, v, vlen, fullScale) {
|
|
568
|
-
var prod; // @return
|
|
569
|
-
var u0, u1, v0, v1; // bc_num
|
|
570
|
-
// var u0len,
|
|
571
|
-
// var v0len // int
|
|
572
|
-
var m1, m2, m3, d1, d2; // bc_num
|
|
573
|
-
var n, prodlen, m1zero; // int
|
|
574
|
-
var d1len, d2len; // int
|
|
575
|
-
// Base case?
|
|
576
|
-
if (ulen + vlen < Libbcmath.MUL_BASE_DIGITS || ulen < Libbcmath.MUL_SMALL_DIGITS || vlen < Libbcmath.MUL_SMALL_DIGITS) {
|
|
577
|
-
return Libbcmath._bc_simp_mul(u, ulen, v, vlen, fullScale);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// Calculate n -- the u and v split point in digits.
|
|
581
|
-
n = Math.floor((Libbcmath.MAX(ulen, vlen) + 1) / 2);
|
|
582
|
-
|
|
583
|
-
// Split u and v.
|
|
584
|
-
if (ulen < n) {
|
|
585
|
-
u1 = Libbcmath.bc_init_num(); // u1 = bc_copy_num (BCG(_zero_));
|
|
586
|
-
u0 = Libbcmath.new_sub_num(ulen, 0, u.n_value);
|
|
587
|
-
} else {
|
|
588
|
-
u1 = Libbcmath.new_sub_num(ulen - n, 0, u.n_value);
|
|
589
|
-
u0 = Libbcmath.new_sub_num(n, 0, u.n_value + ulen - n);
|
|
590
|
-
}
|
|
591
|
-
if (vlen < n) {
|
|
592
|
-
v1 = Libbcmath.bc_init_num(); // bc_copy_num (BCG(_zero_));
|
|
593
|
-
v0 = Libbcmath.new_sub_num(vlen, 0, v.n_value);
|
|
594
|
-
} else {
|
|
595
|
-
v1 = Libbcmath.new_sub_num(vlen - n, 0, v.n_value);
|
|
596
|
-
v0 = Libbcmath.new_sub_num(n, 0, v.n_value + vlen - n);
|
|
597
|
-
}
|
|
598
|
-
Libbcmath._bc_rm_leading_zeros(u1);
|
|
599
|
-
Libbcmath._bc_rm_leading_zeros(u0);
|
|
600
|
-
// var u0len = u0.n_len
|
|
601
|
-
Libbcmath._bc_rm_leading_zeros(v1);
|
|
602
|
-
Libbcmath._bc_rm_leading_zeros(v0);
|
|
603
|
-
// var v0len = v0.n_len
|
|
604
|
-
|
|
605
|
-
m1zero = Libbcmath.bc_is_zero(u1) || Libbcmath.bc_is_zero(v1);
|
|
606
|
-
|
|
607
|
-
// Calculate sub results ...
|
|
608
|
-
d1 = Libbcmath.bc_init_num(); // needed?
|
|
609
|
-
d2 = Libbcmath.bc_init_num(); // needed?
|
|
610
|
-
d1 = Libbcmath.bc_sub(u1, u0, 0);
|
|
611
|
-
d1len = d1.n_len;
|
|
612
|
-
|
|
613
|
-
d2 = Libbcmath.bc_sub(v0, v1, 0);
|
|
614
|
-
d2len = d2.n_len;
|
|
615
|
-
|
|
616
|
-
// Do recursive multiplies and shifted adds.
|
|
617
|
-
if (m1zero) {
|
|
618
|
-
m1 = Libbcmath.bc_init_num(); // bc_copy_num (BCG(_zero_));
|
|
619
|
-
} else {
|
|
620
|
-
// m1 = Libbcmath.bc_init_num(); //allow pass-by-ref
|
|
621
|
-
m1 = Libbcmath._bc_rec_mul(u1, u1.n_len, v1, v1.n_len, 0);
|
|
622
|
-
}
|
|
623
|
-
if (Libbcmath.bc_is_zero(d1) || Libbcmath.bc_is_zero(d2)) {
|
|
624
|
-
m2 = Libbcmath.bc_init_num(); // bc_copy_num (BCG(_zero_));
|
|
625
|
-
} else {
|
|
626
|
-
// m2 = Libbcmath.bc_init_num(); //allow pass-by-ref
|
|
627
|
-
m2 = Libbcmath._bc_rec_mul(d1, d1len, d2, d2len, 0);
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
if (Libbcmath.bc_is_zero(u0) || Libbcmath.bc_is_zero(v0)) {
|
|
631
|
-
m3 = Libbcmath.bc_init_num(); // bc_copy_num (BCG(_zero_));
|
|
632
|
-
} else {
|
|
633
|
-
// m3 = Libbcmath.bc_init_num(); //allow pass-by-ref
|
|
634
|
-
m3 = Libbcmath._bc_rec_mul(u0, u0.n_len, v0, v0.n_len, 0);
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
// Initialize product
|
|
638
|
-
prodlen = ulen + vlen + 1;
|
|
639
|
-
prod = Libbcmath.bc_new_num(prodlen, 0);
|
|
640
|
-
|
|
641
|
-
if (!m1zero) {
|
|
642
|
-
Libbcmath._bc_shift_addsub(prod, m1, 2 * n, 0);
|
|
643
|
-
Libbcmath._bc_shift_addsub(prod, m1, n, 0);
|
|
644
|
-
}
|
|
645
|
-
Libbcmath._bc_shift_addsub(prod, m3, n, 0);
|
|
646
|
-
Libbcmath._bc_shift_addsub(prod, m3, 0, 0);
|
|
647
|
-
Libbcmath._bc_shift_addsub(prod, m2, n, d1.n_sign !== d2.n_sign);
|
|
648
|
-
|
|
649
|
-
return prod;
|
|
650
|
-
// Now clean up!
|
|
651
|
-
// bc_free_num (&u1);
|
|
652
|
-
// bc_free_num (&u0);
|
|
653
|
-
// bc_free_num (&v1);
|
|
654
|
-
// bc_free_num (&m1);
|
|
655
|
-
// bc_free_num (&v0);
|
|
656
|
-
// bc_free_num (&m2);
|
|
657
|
-
// bc_free_num (&m3);
|
|
658
|
-
// bc_free_num (&d1);
|
|
659
|
-
// bc_free_num (&d2);
|
|
660
|
-
},
|
|
661
|
-
|
|
662
|
-
/**
|
|
663
|
-
*
|
|
664
|
-
* @param {bc_num} n1
|
|
665
|
-
* @param {bc_num} n2
|
|
666
|
-
* @param {boolean} useSign
|
|
667
|
-
* @param {boolean} ignoreLast
|
|
668
|
-
* @return -1, 0, 1 (see bc_compare)
|
|
669
|
-
*/
|
|
670
|
-
_bc_do_compare: function _bc_do_compare(n1, n2, useSign, ignoreLast) {
|
|
671
|
-
var n1ptr, n2ptr; // int
|
|
672
|
-
var count; // int
|
|
673
|
-
// First, compare signs.
|
|
674
|
-
if (useSign && n1.n_sign !== n2.n_sign) {
|
|
675
|
-
if (n1.n_sign === Libbcmath.PLUS) {
|
|
676
|
-
return 1; // Positive N1 > Negative N2
|
|
677
|
-
} else {
|
|
678
|
-
return -1; // Negative N1 < Positive N1
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
// Now compare the magnitude.
|
|
683
|
-
if (n1.n_len !== n2.n_len) {
|
|
684
|
-
if (n1.n_len > n2.n_len) {
|
|
685
|
-
// Magnitude of n1 > n2.
|
|
686
|
-
if (!useSign || n1.n_sign === Libbcmath.PLUS) {
|
|
687
|
-
return 1;
|
|
688
|
-
} else {
|
|
689
|
-
return -1;
|
|
690
|
-
}
|
|
691
|
-
} else {
|
|
692
|
-
// Magnitude of n1 < n2.
|
|
693
|
-
if (!useSign || n1.n_sign === Libbcmath.PLUS) {
|
|
694
|
-
return -1;
|
|
695
|
-
} else {
|
|
696
|
-
return 1;
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/* If we get here, they have the same number of integer digits.
|
|
702
|
-
check the integer part and the equal length part of the fraction. */
|
|
703
|
-
count = n1.n_len + Math.min(n1.n_scale, n2.n_scale);
|
|
704
|
-
n1ptr = 0;
|
|
705
|
-
n2ptr = 0;
|
|
706
|
-
|
|
707
|
-
while (count > 0 && n1.n_value[n1ptr] === n2.n_value[n2ptr]) {
|
|
708
|
-
n1ptr++;
|
|
709
|
-
n2ptr++;
|
|
710
|
-
count--;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
if (ignoreLast && count === 1 && n1.n_scale === n2.n_scale) {
|
|
714
|
-
return 0;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
if (count !== 0) {
|
|
718
|
-
if (n1.n_value[n1ptr] > n2.n_value[n2ptr]) {
|
|
719
|
-
// Magnitude of n1 > n2.
|
|
720
|
-
if (!useSign || n1.n_sign === Libbcmath.PLUS) {
|
|
721
|
-
return 1;
|
|
722
|
-
} else {
|
|
723
|
-
return -1;
|
|
724
|
-
}
|
|
725
|
-
} else {
|
|
726
|
-
// Magnitude of n1 < n2.
|
|
727
|
-
if (!useSign || n1.n_sign === Libbcmath.PLUS) {
|
|
728
|
-
return -1;
|
|
729
|
-
} else {
|
|
730
|
-
return 1;
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// They are equal up to the last part of the equal part of the fraction.
|
|
736
|
-
if (n1.n_scale !== n2.n_scale) {
|
|
737
|
-
if (n1.n_scale > n2.n_scale) {
|
|
738
|
-
for (count = n1.n_scale - n2.n_scale; count > 0; count--) {
|
|
739
|
-
if (n1.n_value[n1ptr++] !== 0) {
|
|
740
|
-
// Magnitude of n1 > n2.
|
|
741
|
-
if (!useSign || n1.n_sign === Libbcmath.PLUS) {
|
|
742
|
-
return 1;
|
|
743
|
-
} else {
|
|
744
|
-
return -1;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
} else {
|
|
749
|
-
for (count = n2.n_scale - n1.n_scale; count > 0; count--) {
|
|
750
|
-
if (n2.n_value[n2ptr++] !== 0) {
|
|
751
|
-
// Magnitude of n1 < n2.
|
|
752
|
-
if (!useSign || n1.n_sign === Libbcmath.PLUS) {
|
|
753
|
-
return -1;
|
|
754
|
-
} else {
|
|
755
|
-
return 1;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// They must be equal!
|
|
763
|
-
return 0;
|
|
764
|
-
},
|
|
765
|
-
|
|
766
|
-
/* Here is the full subtract routine that takes care of negative numbers.
|
|
767
|
-
N2 is subtracted from N1 and the result placed in RESULT. SCALE_MIN
|
|
768
|
-
is the minimum scale for the result. */
|
|
769
|
-
bc_sub: function bc_sub(n1, n2, scaleMin) {
|
|
770
|
-
var diff; // bc_num
|
|
771
|
-
var cmpRes, resScale; // int
|
|
772
|
-
if (n1.n_sign !== n2.n_sign) {
|
|
773
|
-
diff = Libbcmath._bc_do_add(n1, n2, scaleMin);
|
|
774
|
-
diff.n_sign = n1.n_sign;
|
|
775
|
-
} else {
|
|
776
|
-
// subtraction must be done.
|
|
777
|
-
// Compare magnitudes.
|
|
778
|
-
cmpRes = Libbcmath._bc_do_compare(n1, n2, false, false);
|
|
779
|
-
switch (cmpRes) {
|
|
780
|
-
case -1:
|
|
781
|
-
// n1 is less than n2, subtract n1 from n2.
|
|
782
|
-
diff = Libbcmath._bc_do_sub(n2, n1, scaleMin);
|
|
783
|
-
diff.n_sign = n2.n_sign === Libbcmath.PLUS ? Libbcmath.MINUS : Libbcmath.PLUS;
|
|
784
|
-
break;
|
|
785
|
-
case 0:
|
|
786
|
-
// They are equal! return zero!
|
|
787
|
-
resScale = Libbcmath.MAX(scaleMin, Libbcmath.MAX(n1.n_scale, n2.n_scale));
|
|
788
|
-
diff = Libbcmath.bc_new_num(1, resScale);
|
|
789
|
-
Libbcmath.memset(diff.n_value, 0, 0, resScale + 1);
|
|
790
|
-
break;
|
|
791
|
-
case 1:
|
|
792
|
-
// n2 is less than n1, subtract n2 from n1.
|
|
793
|
-
diff = Libbcmath._bc_do_sub(n1, n2, scaleMin);
|
|
794
|
-
diff.n_sign = n1.n_sign;
|
|
795
|
-
break;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
// Clean up and return.
|
|
800
|
-
// bc_free_num (result);
|
|
801
|
-
//* result = diff;
|
|
802
|
-
return diff;
|
|
803
|
-
},
|
|
804
|
-
|
|
805
|
-
_bc_do_add: function _bc_do_add(n1, n2, scaleMin) {
|
|
806
|
-
var sum; // bc_num
|
|
807
|
-
var sumScale, sumDigits; // int
|
|
808
|
-
var n1ptr, n2ptr, sumptr; // int
|
|
809
|
-
var carry, n1bytes, n2bytes; // int
|
|
810
|
-
var tmp; // int
|
|
811
|
-
|
|
812
|
-
// Prepare sum.
|
|
813
|
-
sumScale = Libbcmath.MAX(n1.n_scale, n2.n_scale);
|
|
814
|
-
sumDigits = Libbcmath.MAX(n1.n_len, n2.n_len) + 1;
|
|
815
|
-
sum = Libbcmath.bc_new_num(sumDigits, Libbcmath.MAX(sumScale, scaleMin));
|
|
816
|
-
|
|
817
|
-
// Start with the fraction part. Initialize the pointers.
|
|
818
|
-
n1bytes = n1.n_scale;
|
|
819
|
-
n2bytes = n2.n_scale;
|
|
820
|
-
n1ptr = n1.n_len + n1bytes - 1;
|
|
821
|
-
n2ptr = n2.n_len + n2bytes - 1;
|
|
822
|
-
sumptr = sumScale + sumDigits - 1;
|
|
823
|
-
|
|
824
|
-
// Add the fraction part. First copy the longer fraction
|
|
825
|
-
// (ie when adding 1.2345 to 1 we know .2345 is correct already) .
|
|
826
|
-
if (n1bytes !== n2bytes) {
|
|
827
|
-
if (n1bytes > n2bytes) {
|
|
828
|
-
// n1 has more dp then n2
|
|
829
|
-
while (n1bytes > n2bytes) {
|
|
830
|
-
sum.n_value[sumptr--] = n1.n_value[n1ptr--];
|
|
831
|
-
// *sumptr-- = *n1ptr--;
|
|
832
|
-
n1bytes--;
|
|
833
|
-
}
|
|
834
|
-
} else {
|
|
835
|
-
// n2 has more dp then n1
|
|
836
|
-
while (n2bytes > n1bytes) {
|
|
837
|
-
sum.n_value[sumptr--] = n2.n_value[n2ptr--];
|
|
838
|
-
// *sumptr-- = *n2ptr--;
|
|
839
|
-
n2bytes--;
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
// Now add the remaining fraction part and equal size integer parts.
|
|
845
|
-
n1bytes += n1.n_len;
|
|
846
|
-
n2bytes += n2.n_len;
|
|
847
|
-
carry = 0;
|
|
848
|
-
while (n1bytes > 0 && n2bytes > 0) {
|
|
849
|
-
// add the two numbers together
|
|
850
|
-
tmp = n1.n_value[n1ptr--] + n2.n_value[n2ptr--] + carry;
|
|
851
|
-
// *sumptr = *n1ptr-- + *n2ptr-- + carry;
|
|
852
|
-
// check if they are >= 10 (impossible to be more then 18)
|
|
853
|
-
if (tmp >= Libbcmath.BASE) {
|
|
854
|
-
carry = 1;
|
|
855
|
-
tmp -= Libbcmath.BASE; // yep, subtract 10, add a carry
|
|
856
|
-
} else {
|
|
857
|
-
carry = 0;
|
|
858
|
-
}
|
|
859
|
-
sum.n_value[sumptr] = tmp;
|
|
860
|
-
sumptr--;
|
|
861
|
-
n1bytes--;
|
|
862
|
-
n2bytes--;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
// Now add carry the [rest of the] longer integer part.
|
|
866
|
-
if (n1bytes === 0) {
|
|
867
|
-
// n2 is a bigger number then n1
|
|
868
|
-
while (n2bytes-- > 0) {
|
|
869
|
-
tmp = n2.n_value[n2ptr--] + carry;
|
|
870
|
-
// *sumptr = *n2ptr-- + carry;
|
|
871
|
-
if (tmp >= Libbcmath.BASE) {
|
|
872
|
-
carry = 1;
|
|
873
|
-
tmp -= Libbcmath.BASE;
|
|
874
|
-
} else {
|
|
875
|
-
carry = 0;
|
|
876
|
-
}
|
|
877
|
-
sum.n_value[sumptr--] = tmp;
|
|
878
|
-
}
|
|
879
|
-
} else {
|
|
880
|
-
// n1 is bigger then n2..
|
|
881
|
-
while (n1bytes-- > 0) {
|
|
882
|
-
tmp = n1.n_value[n1ptr--] + carry;
|
|
883
|
-
// *sumptr = *n1ptr-- + carry;
|
|
884
|
-
if (tmp >= Libbcmath.BASE) {
|
|
885
|
-
carry = 1;
|
|
886
|
-
tmp -= Libbcmath.BASE;
|
|
887
|
-
} else {
|
|
888
|
-
carry = 0;
|
|
889
|
-
}
|
|
890
|
-
sum.n_value[sumptr--] = tmp;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
// Set final carry.
|
|
895
|
-
if (carry === 1) {
|
|
896
|
-
sum.n_value[sumptr] += 1;
|
|
897
|
-
// *sumptr += 1;
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
// Adjust sum and return.
|
|
901
|
-
Libbcmath._bc_rm_leading_zeros(sum);
|
|
902
|
-
return sum;
|
|
903
|
-
},
|
|
904
|
-
|
|
905
|
-
/**
|
|
906
|
-
* Perform a subtraction
|
|
907
|
-
*
|
|
908
|
-
* Perform subtraction: N2 is subtracted from N1 and the value is
|
|
909
|
-
* returned. The signs of N1 and N2 are ignored. Also, N1 is
|
|
910
|
-
* assumed to be larger than N2. SCALE_MIN is the minimum scale
|
|
911
|
-
* of the result.
|
|
912
|
-
*
|
|
913
|
-
* Basic school maths says to subtract 2 numbers..
|
|
914
|
-
* 1. make them the same length, the decimal places, and the integer part
|
|
915
|
-
* 2. start from the right and subtract the two numbers from each other
|
|
916
|
-
* 3. if the sum of the 2 numbers < 0, carry -1 to the next set and add 10
|
|
917
|
-
* (ie 18 > carry 1 becomes 8). thus 0.9 + 0.9 = 1.8
|
|
918
|
-
*
|
|
919
|
-
* @param {bc_num} n1
|
|
920
|
-
* @param {bc_num} n2
|
|
921
|
-
* @param {int} scaleMin
|
|
922
|
-
* @return bc_num
|
|
923
|
-
*/
|
|
924
|
-
_bc_do_sub: function _bc_do_sub(n1, n2, scaleMin) {
|
|
925
|
-
var diff; // bc_num
|
|
926
|
-
var diffScale, diffLen; // int
|
|
927
|
-
var minScale, minLen; // int
|
|
928
|
-
var n1ptr, n2ptr, diffptr; // int
|
|
929
|
-
var borrow, count, val; // int
|
|
930
|
-
// Allocate temporary storage.
|
|
931
|
-
diffLen = Libbcmath.MAX(n1.n_len, n2.n_len);
|
|
932
|
-
diffScale = Libbcmath.MAX(n1.n_scale, n2.n_scale);
|
|
933
|
-
minLen = Libbcmath.MIN(n1.n_len, n2.n_len);
|
|
934
|
-
minScale = Libbcmath.MIN(n1.n_scale, n2.n_scale);
|
|
935
|
-
diff = Libbcmath.bc_new_num(diffLen, Libbcmath.MAX(diffScale, scaleMin));
|
|
936
|
-
|
|
937
|
-
/* Not needed?
|
|
938
|
-
// Zero extra digits made by scaleMin.
|
|
939
|
-
if (scaleMin > diffScale) {
|
|
940
|
-
diffptr = (char *) (diff->n_value + diffLen + diffScale);
|
|
941
|
-
for (count = scaleMin - diffScale; count > 0; count--) {
|
|
942
|
-
*diffptr++ = 0;
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
*/
|
|
946
|
-
|
|
947
|
-
// Initialize the subtract.
|
|
948
|
-
n1ptr = n1.n_len + n1.n_scale - 1;
|
|
949
|
-
n2ptr = n2.n_len + n2.n_scale - 1;
|
|
950
|
-
diffptr = diffLen + diffScale - 1;
|
|
951
|
-
|
|
952
|
-
// Subtract the numbers.
|
|
953
|
-
borrow = 0;
|
|
954
|
-
|
|
955
|
-
// Take care of the longer scaled number.
|
|
956
|
-
if (n1.n_scale !== minScale) {
|
|
957
|
-
// n1 has the longer scale
|
|
958
|
-
for (count = n1.n_scale - minScale; count > 0; count--) {
|
|
959
|
-
diff.n_value[diffptr--] = n1.n_value[n1ptr--];
|
|
960
|
-
// *diffptr-- = *n1ptr--;
|
|
961
|
-
}
|
|
962
|
-
} else {
|
|
963
|
-
// n2 has the longer scale
|
|
964
|
-
for (count = n2.n_scale - minScale; count > 0; count--) {
|
|
965
|
-
val = 0 - n2.n_value[n2ptr--] - borrow;
|
|
966
|
-
// val = - *n2ptr-- - borrow;
|
|
967
|
-
if (val < 0) {
|
|
968
|
-
val += Libbcmath.BASE;
|
|
969
|
-
borrow = 1;
|
|
970
|
-
} else {
|
|
971
|
-
borrow = 0;
|
|
972
|
-
}
|
|
973
|
-
diff.n_value[diffptr--] = val;
|
|
974
|
-
//* diffptr-- = val;
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
// Now do the equal length scale and integer parts.
|
|
979
|
-
for (count = 0; count < minLen + minScale; count++) {
|
|
980
|
-
val = n1.n_value[n1ptr--] - n2.n_value[n2ptr--] - borrow;
|
|
981
|
-
// val = *n1ptr-- - *n2ptr-- - borrow;
|
|
982
|
-
if (val < 0) {
|
|
983
|
-
val += Libbcmath.BASE;
|
|
984
|
-
borrow = 1;
|
|
985
|
-
} else {
|
|
986
|
-
borrow = 0;
|
|
987
|
-
}
|
|
988
|
-
diff.n_value[diffptr--] = val;
|
|
989
|
-
//* diffptr-- = val;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
// If n1 has more digits then n2, we now do that subtract.
|
|
993
|
-
if (diffLen !== minLen) {
|
|
994
|
-
for (count = diffLen - minLen; count > 0; count--) {
|
|
995
|
-
val = n1.n_value[n1ptr--] - borrow;
|
|
996
|
-
// val = *n1ptr-- - borrow;
|
|
997
|
-
if (val < 0) {
|
|
998
|
-
val += Libbcmath.BASE;
|
|
999
|
-
borrow = 1;
|
|
1000
|
-
} else {
|
|
1001
|
-
borrow = 0;
|
|
1002
|
-
}
|
|
1003
|
-
diff.n_value[diffptr--] = val;
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
// Clean up and return.
|
|
1008
|
-
Libbcmath._bc_rm_leading_zeros(diff);
|
|
1009
|
-
return diff;
|
|
1010
|
-
},
|
|
1011
|
-
|
|
1012
|
-
/**
|
|
1013
|
-
*
|
|
1014
|
-
* @param {int} length
|
|
1015
|
-
* @param {int} scale
|
|
1016
|
-
* @return bc_num
|
|
1017
|
-
*/
|
|
1018
|
-
bc_new_num: function bc_new_num(length, scale) {
|
|
1019
|
-
var temp; // bc_num
|
|
1020
|
-
temp = new Libbcmath.bc_num(); // eslint-disable-line new-cap
|
|
1021
|
-
temp.n_sign = Libbcmath.PLUS;
|
|
1022
|
-
temp.n_len = length;
|
|
1023
|
-
temp.n_scale = scale;
|
|
1024
|
-
temp.n_value = Libbcmath.safe_emalloc(1, length + scale, 0);
|
|
1025
|
-
Libbcmath.memset(temp.n_value, 0, 0, length + scale);
|
|
1026
|
-
return temp;
|
|
1027
|
-
},
|
|
1028
|
-
|
|
1029
|
-
safe_emalloc: function safe_emalloc(size, len, extra) {
|
|
1030
|
-
return Array(size * len + extra);
|
|
1031
|
-
},
|
|
1032
|
-
|
|
1033
|
-
/**
|
|
1034
|
-
* Create a new number
|
|
1035
|
-
*/
|
|
1036
|
-
bc_init_num: function bc_init_num() {
|
|
1037
|
-
return new Libbcmath.bc_new_num(1, 0); // eslint-disable-line new-cap
|
|
1038
|
-
},
|
|
1039
|
-
|
|
1040
|
-
_bc_rm_leading_zeros: function _bc_rm_leading_zeros(num) {
|
|
1041
|
-
// We can move n_value to point to the first non zero digit!
|
|
1042
|
-
while (num.n_value[0] === 0 && num.n_len > 1) {
|
|
1043
|
-
num.n_value.shift();
|
|
1044
|
-
num.n_len--;
|
|
1045
|
-
}
|
|
1046
|
-
},
|
|
1047
|
-
|
|
1048
|
-
/**
|
|
1049
|
-
* Convert to bc_num detecting scale
|
|
1050
|
-
*/
|
|
1051
|
-
php_str2num: function php_str2num(str) {
|
|
1052
|
-
var p;
|
|
1053
|
-
p = str.indexOf('.');
|
|
1054
|
-
if (p === -1) {
|
|
1055
|
-
return Libbcmath.bc_str2num(str, 0);
|
|
1056
|
-
} else {
|
|
1057
|
-
return Libbcmath.bc_str2num(str, str.length - p);
|
|
1058
|
-
}
|
|
1059
|
-
},
|
|
1060
|
-
|
|
1061
|
-
CH_VAL: function CH_VAL(c) {
|
|
1062
|
-
return c - '0'; // ??
|
|
1063
|
-
},
|
|
1064
|
-
|
|
1065
|
-
BCD_CHAR: function BCD_CHAR(d) {
|
|
1066
|
-
return d + '0'; // ??
|
|
1067
|
-
},
|
|
1068
|
-
|
|
1069
|
-
isdigit: function isdigit(c) {
|
|
1070
|
-
return isNaN(parseInt(c, 10));
|
|
1071
|
-
},
|
|
1072
|
-
|
|
1073
|
-
bc_str2num: function bc_str2num(strIn, scale) {
|
|
1074
|
-
var str, num, ptr, digits, strscale, zeroInt, nptr;
|
|
1075
|
-
// remove any non-expected characters
|
|
1076
|
-
// Check for valid number and count digits.
|
|
1077
|
-
|
|
1078
|
-
str = strIn.split(''); // convert to array
|
|
1079
|
-
ptr = 0; // str
|
|
1080
|
-
digits = 0;
|
|
1081
|
-
strscale = 0;
|
|
1082
|
-
zeroInt = false;
|
|
1083
|
-
if (str[ptr] === '+' || str[ptr] === '-') {
|
|
1084
|
-
ptr++; // Sign
|
|
1085
|
-
}
|
|
1086
|
-
while (str[ptr] === '0') {
|
|
1087
|
-
ptr++; // Skip leading zeros.
|
|
1088
|
-
}
|
|
1089
|
-
// while (Libbcmath.isdigit(str[ptr])) {
|
|
1090
|
-
while (str[ptr] % 1 === 0) {
|
|
1091
|
-
// Libbcmath.isdigit(str[ptr])) {
|
|
1092
|
-
ptr++;
|
|
1093
|
-
digits++; // digits
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
if (str[ptr] === '.') {
|
|
1097
|
-
ptr++; // decimal point
|
|
1098
|
-
}
|
|
1099
|
-
// while (Libbcmath.isdigit(str[ptr])) {
|
|
1100
|
-
while (str[ptr] % 1 === 0) {
|
|
1101
|
-
// Libbcmath.isdigit(str[ptr])) {
|
|
1102
|
-
ptr++;
|
|
1103
|
-
strscale++; // digits
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
if (str[ptr] || digits + strscale === 0) {
|
|
1107
|
-
// invalid number, return 0
|
|
1108
|
-
return Libbcmath.bc_init_num();
|
|
1109
|
-
//* num = bc_copy_num (BCG(_zero_));
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
// Adjust numbers and allocate storage and initialize fields.
|
|
1113
|
-
strscale = Libbcmath.MIN(strscale, scale);
|
|
1114
|
-
if (digits === 0) {
|
|
1115
|
-
zeroInt = true;
|
|
1116
|
-
digits = 1;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
num = Libbcmath.bc_new_num(digits, strscale);
|
|
1120
|
-
|
|
1121
|
-
// Build the whole number.
|
|
1122
|
-
ptr = 0; // str
|
|
1123
|
-
if (str[ptr] === '-') {
|
|
1124
|
-
num.n_sign = Libbcmath.MINUS;
|
|
1125
|
-
// (*num)->n_sign = MINUS;
|
|
1126
|
-
ptr++;
|
|
1127
|
-
} else {
|
|
1128
|
-
num.n_sign = Libbcmath.PLUS;
|
|
1129
|
-
// (*num)->n_sign = PLUS;
|
|
1130
|
-
if (str[ptr] === '+') {
|
|
1131
|
-
ptr++;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
while (str[ptr] === '0') {
|
|
1135
|
-
ptr++; // Skip leading zeros.
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
nptr = 0; // (*num)->n_value;
|
|
1139
|
-
if (zeroInt) {
|
|
1140
|
-
num.n_value[nptr++] = 0;
|
|
1141
|
-
digits = 0;
|
|
1142
|
-
}
|
|
1143
|
-
for (; digits > 0; digits--) {
|
|
1144
|
-
num.n_value[nptr++] = Libbcmath.CH_VAL(str[ptr++]);
|
|
1145
|
-
//* nptr++ = CH_VAL(*ptr++);
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
// Build the fractional part.
|
|
1149
|
-
if (strscale > 0) {
|
|
1150
|
-
ptr++; // skip the decimal point!
|
|
1151
|
-
for (; strscale > 0; strscale--) {
|
|
1152
|
-
num.n_value[nptr++] = Libbcmath.CH_VAL(str[ptr++]);
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
return num;
|
|
1157
|
-
},
|
|
1158
|
-
|
|
1159
|
-
cint: function cint(v) {
|
|
1160
|
-
if (typeof v === 'undefined') {
|
|
1161
|
-
v = 0;
|
|
1162
|
-
}
|
|
1163
|
-
var x = parseInt(v, 10);
|
|
1164
|
-
if (isNaN(x)) {
|
|
1165
|
-
x = 0;
|
|
1166
|
-
}
|
|
1167
|
-
return x;
|
|
1168
|
-
},
|
|
1169
|
-
|
|
1170
|
-
/**
|
|
1171
|
-
* Basic min function
|
|
1172
|
-
* @param {int} a
|
|
1173
|
-
* @param {int} b
|
|
1174
|
-
*/
|
|
1175
|
-
MIN: function MIN(a, b) {
|
|
1176
|
-
return a > b ? b : a;
|
|
1177
|
-
},
|
|
1178
|
-
|
|
1179
|
-
/**
|
|
1180
|
-
* Basic max function
|
|
1181
|
-
* @param {int} a
|
|
1182
|
-
* @param {int} b
|
|
1183
|
-
*/
|
|
1184
|
-
MAX: function MAX(a, b) {
|
|
1185
|
-
return a > b ? a : b;
|
|
1186
|
-
},
|
|
1187
|
-
|
|
1188
|
-
/**
|
|
1189
|
-
* Basic odd function
|
|
1190
|
-
* @param {int} a
|
|
1191
|
-
*/
|
|
1192
|
-
ODD: function ODD(a) {
|
|
1193
|
-
return a & 1;
|
|
1194
|
-
},
|
|
1195
|
-
|
|
1196
|
-
/**
|
|
1197
|
-
* replicate c function
|
|
1198
|
-
* @param {array} r return (by reference)
|
|
1199
|
-
* @param {int} ptr
|
|
1200
|
-
* @param {string} chr char to fill
|
|
1201
|
-
* @param {int} len length to fill
|
|
1202
|
-
*/
|
|
1203
|
-
memset: function memset(r, ptr, chr, len) {
|
|
1204
|
-
var i;
|
|
1205
|
-
for (i = 0; i < len; i++) {
|
|
1206
|
-
r[ptr + i] = chr;
|
|
1207
|
-
}
|
|
1208
|
-
},
|
|
1209
|
-
|
|
1210
|
-
/**
|
|
1211
|
-
* Replacement c function
|
|
1212
|
-
* Obviously can't work like c does, so we've added an "offset"
|
|
1213
|
-
* param so you could do memcpy(dest+1, src, len) as memcpy(dest, 1, src, len)
|
|
1214
|
-
* Also only works on arrays
|
|
1215
|
-
*/
|
|
1216
|
-
memcpy: function memcpy(dest, ptr, src, srcptr, len) {
|
|
1217
|
-
var i;
|
|
1218
|
-
for (i = 0; i < len; i++) {
|
|
1219
|
-
dest[ptr + i] = src[srcptr + i];
|
|
1220
|
-
}
|
|
1221
|
-
return true;
|
|
1222
|
-
},
|
|
1223
|
-
|
|
1224
|
-
/**
|
|
1225
|
-
* Determine if the number specified is zero or not
|
|
1226
|
-
* @param {bc_num} num number to check
|
|
1227
|
-
* @return boolean true when zero, false when not zero.
|
|
1228
|
-
*/
|
|
1229
|
-
bc_is_zero: function bc_is_zero(num) {
|
|
1230
|
-
var count; // int
|
|
1231
|
-
var nptr; // int
|
|
1232
|
-
// Quick check.
|
|
1233
|
-
// if (num === BCG(_zero_)) return TRUE;
|
|
1234
|
-
// Initialize
|
|
1235
|
-
count = num.n_len + num.n_scale;
|
|
1236
|
-
nptr = 0; // num->n_value;
|
|
1237
|
-
// The check
|
|
1238
|
-
while (count > 0 && num.n_value[nptr++] === 0) {
|
|
1239
|
-
count--;
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
if (count !== 0) {
|
|
1243
|
-
return false;
|
|
1244
|
-
} else {
|
|
1245
|
-
return true;
|
|
1246
|
-
}
|
|
1247
|
-
},
|
|
1248
|
-
|
|
1249
|
-
bc_out_of_memory: function bc_out_of_memory() {
|
|
1250
|
-
throw new Error('(BC) Out of memory');
|
|
1251
|
-
}
|
|
1252
|
-
};
|
|
1253
|
-
return Libbcmath;
|
|
1254
|
-
};
|
|
1255
|
-
//# sourceMappingURL=_bc.js.map
|