You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

574 lines
15 KiB

28 years ago
28 years ago
28 years ago
27 years ago
27 years ago
28 years ago
25 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
24 years ago
28 years ago
28 years ago
28 years ago
25 years ago
24 years ago
28 years ago
25 years ago
24 years ago
27 years ago
28 years ago
27 years ago
24 years ago
25 years ago
24 years ago
24 years ago
28 years ago
27 years ago
28 years ago
24 years ago
28 years ago
28 years ago
28 years ago
25 years ago
24 years ago
28 years ago
25 years ago
24 years ago
27 years ago
28 years ago
27 years ago
24 years ago
25 years ago
24 years ago
24 years ago
28 years ago
28 years ago
24 years ago
28 years ago
28 years ago
28 years ago
25 years ago
24 years ago
28 years ago
25 years ago
24 years ago
27 years ago
28 years ago
27 years ago
24 years ago
24 years ago
24 years ago
28 years ago
28 years ago
24 years ago
28 years ago
28 years ago
28 years ago
25 years ago
24 years ago
28 years ago
25 years ago
24 years ago
27 years ago
28 years ago
27 years ago
24 years ago
28 years ago
24 years ago
24 years ago
28 years ago
28 years ago
28 years ago
28 years ago
24 years ago
28 years ago
28 years ago
25 years ago
24 years ago
28 years ago
27 years ago
28 years ago
28 years ago
28 years ago
28 years ago
23 years ago
24 years ago
24 years ago
24 years ago
24 years ago
28 years ago
28 years ago
24 years ago
28 years ago
28 years ago
28 years ago
25 years ago
24 years ago
28 years ago
25 years ago
24 years ago
27 years ago
28 years ago
27 years ago
24 years ago
24 years ago
24 years ago
28 years ago
28 years ago
24 years ago
28 years ago
28 years ago
28 years ago
24 years ago
28 years ago
25 years ago
24 years ago
27 years ago
28 years ago
27 years ago
24 years ago
24 years ago
24 years ago
28 years ago
28 years ago
28 years ago
23 years ago
28 years ago
28 years ago
24 years ago
28 years ago
28 years ago
28 years ago
25 years ago
24 years ago
28 years ago
25 years ago
24 years ago
27 years ago
28 years ago
27 years ago
28 years ago
28 years ago
28 years ago
23 years ago
28 years ago
28 years ago
24 years ago
28 years ago
24 years ago
28 years ago
27 years ago
28 years ago
28 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2006 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Author: Andi Gutmans <andi@zend.com> |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. #include "php.h"
  23. #if HAVE_BCMATH
  24. #include "php_ini.h"
  25. #include "ext/standard/info.h"
  26. #include "php_bcmath.h"
  27. #include "libbcmath/src/bcmath.h"
  28. ZEND_DECLARE_MODULE_GLOBALS(bcmath);
  29. zend_function_entry bcmath_functions[] = {
  30. PHP_FE(bcadd, NULL)
  31. PHP_FE(bcsub, NULL)
  32. PHP_FE(bcmul, NULL)
  33. PHP_FE(bcdiv, NULL)
  34. PHP_FE(bcmod, NULL)
  35. PHP_FE(bcpow, NULL)
  36. PHP_FE(bcsqrt, NULL)
  37. PHP_FE(bcscale, NULL)
  38. PHP_FE(bccomp, NULL)
  39. PHP_FE(bcpowmod, NULL)
  40. {NULL, NULL, NULL}
  41. };
  42. zend_module_entry bcmath_module_entry = {
  43. STANDARD_MODULE_HEADER,
  44. "bcmath",
  45. bcmath_functions,
  46. PHP_MINIT(bcmath),
  47. PHP_MSHUTDOWN(bcmath),
  48. PHP_RINIT(bcmath),
  49. PHP_RSHUTDOWN(bcmath),
  50. PHP_MINFO(bcmath),
  51. NO_VERSION_YET,
  52. STANDARD_MODULE_PROPERTIES
  53. };
  54. #ifdef COMPILE_DL_BCMATH
  55. ZEND_GET_MODULE(bcmath)
  56. #endif
  57. /* {{{ PHP_INI */
  58. PHP_INI_BEGIN()
  59. STD_PHP_INI_ENTRY("bcmath.scale", "0", PHP_INI_ALL, OnUpdateLong, bc_precision, zend_bcmath_globals, bcmath_globals)
  60. PHP_INI_END()
  61. /* }}} */
  62. /* {{{ php_bcmath_init_globals
  63. */
  64. static void php_bcmath_init_globals(zend_bcmath_globals *bcmath_globals)
  65. {
  66. bcmath_globals->bc_precision = 0;
  67. }
  68. /* }}} */
  69. /* {{{ PHP_MINIT_FUNCTION
  70. */
  71. PHP_MINIT_FUNCTION(bcmath)
  72. {
  73. ZEND_INIT_MODULE_GLOBALS(bcmath, php_bcmath_init_globals, NULL);
  74. REGISTER_INI_ENTRIES();
  75. return SUCCESS;
  76. }
  77. /* }}} */
  78. /* {{{ PHP_MSHUTDOWN_FUNCTION
  79. */
  80. PHP_MSHUTDOWN_FUNCTION(bcmath)
  81. {
  82. UNREGISTER_INI_ENTRIES();
  83. return SUCCESS;
  84. }
  85. /* }}} */
  86. /* {{{ PHP_RINIT_FUNCTION
  87. */
  88. PHP_RINIT_FUNCTION(bcmath)
  89. {
  90. bc_init_numbers(TSRMLS_C);
  91. return SUCCESS;
  92. }
  93. /* }}} */
  94. /* {{{ PHP_RSHUTDOWN_FUNCTION
  95. */
  96. PHP_RSHUTDOWN_FUNCTION(bcmath)
  97. {
  98. _bc_free_num_ex(&BCG(_zero_), 1);
  99. _bc_free_num_ex(&BCG(_one_), 1);
  100. _bc_free_num_ex(&BCG(_two_), 1);
  101. return SUCCESS;
  102. }
  103. /* }}} */
  104. /* {{{ PHP_MINFO_FUNCTION
  105. */
  106. PHP_MINFO_FUNCTION(bcmath)
  107. {
  108. php_info_print_table_start();
  109. php_info_print_table_row(2, "BCMath support", "enabled");
  110. php_info_print_table_end();
  111. }
  112. /* }}} */
  113. /* {{{ php_str2num
  114. Convert to bc_num detecting scale */
  115. static void php_str2num(bc_num *num, char *str TSRMLS_DC)
  116. {
  117. char *p;
  118. if (!(p = strchr(str, '.'))) {
  119. bc_str2num(num, str, 0 TSRMLS_CC);
  120. return;
  121. }
  122. bc_str2num(num, str, strlen(p+1) TSRMLS_CC);
  123. }
  124. /* }}} */
  125. /* {{{ proto string bcadd(string left_operand, string right_operand [, int scale])
  126. Returns the sum of two arbitrary precision numbers */
  127. PHP_FUNCTION(bcadd)
  128. {
  129. zval **left, **right, **scale_param;
  130. bc_num first, second, result;
  131. int scale = BCG(bc_precision);
  132. switch (ZEND_NUM_ARGS()) {
  133. case 2:
  134. if (zend_get_parameters_ex(2, &left, &right) == FAILURE) {
  135. WRONG_PARAM_COUNT;
  136. }
  137. break;
  138. case 3:
  139. if (zend_get_parameters_ex(3, &left, &right, &scale_param) == FAILURE) {
  140. WRONG_PARAM_COUNT;
  141. }
  142. convert_to_long_ex(scale_param);
  143. scale = (int) (Z_LVAL_PP(scale_param) < 0) ? 0 : Z_LVAL_PP(scale_param);
  144. break;
  145. default:
  146. WRONG_PARAM_COUNT;
  147. break;
  148. }
  149. convert_to_string_ex(left);
  150. convert_to_string_ex(right);
  151. bc_init_num(&first TSRMLS_CC);
  152. bc_init_num(&second TSRMLS_CC);
  153. bc_init_num(&result TSRMLS_CC);
  154. php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
  155. php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
  156. bc_add (first, second, &result, scale);
  157. if (result->n_scale > scale) {
  158. result->n_scale = scale;
  159. }
  160. Z_STRVAL_P(return_value) = bc_num2str(result);
  161. Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
  162. Z_TYPE_P(return_value) = IS_STRING;
  163. bc_free_num(&first);
  164. bc_free_num(&second);
  165. bc_free_num(&result);
  166. return;
  167. }
  168. /* }}} */
  169. /* {{{ proto string bcsub(string left_operand, string right_operand [, int scale])
  170. Returns the difference between two arbitrary precision numbers */
  171. PHP_FUNCTION(bcsub)
  172. {
  173. zval **left, **right, **scale_param;
  174. bc_num first, second, result;
  175. int scale = BCG(bc_precision);
  176. switch (ZEND_NUM_ARGS()) {
  177. case 2:
  178. if (zend_get_parameters_ex(2, &left, &right) == FAILURE) {
  179. WRONG_PARAM_COUNT;
  180. }
  181. break;
  182. case 3:
  183. if (zend_get_parameters_ex(3, &left, &right, &scale_param) == FAILURE) {
  184. WRONG_PARAM_COUNT;
  185. }
  186. convert_to_long_ex(scale_param);
  187. scale = (int) (Z_LVAL_PP(scale_param) < 0) ? 0 : Z_LVAL_PP(scale_param);
  188. break;
  189. default:
  190. WRONG_PARAM_COUNT;
  191. break;
  192. }
  193. convert_to_string_ex(left);
  194. convert_to_string_ex(right);
  195. bc_init_num(&first TSRMLS_CC);
  196. bc_init_num(&second TSRMLS_CC);
  197. bc_init_num(&result TSRMLS_CC);
  198. php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
  199. php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
  200. bc_sub (first, second, &result, scale);
  201. if (result->n_scale > scale) {
  202. result->n_scale = scale;
  203. }
  204. Z_STRVAL_P(return_value) = bc_num2str(result);
  205. Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
  206. Z_TYPE_P(return_value) = IS_STRING;
  207. bc_free_num(&first);
  208. bc_free_num(&second);
  209. bc_free_num(&result);
  210. return;
  211. }
  212. /* }}} */
  213. /* {{{ proto string bcmul(string left_operand, string right_operand [, int scale])
  214. Returns the multiplication of two arbitrary precision numbers */
  215. PHP_FUNCTION(bcmul)
  216. {
  217. zval **left, **right, **scale_param;
  218. bc_num first, second, result;
  219. int scale = BCG(bc_precision);
  220. switch (ZEND_NUM_ARGS()) {
  221. case 2:
  222. if (zend_get_parameters_ex(2, &left, &right) == FAILURE) {
  223. WRONG_PARAM_COUNT;
  224. }
  225. break;
  226. case 3:
  227. if (zend_get_parameters_ex(3, &left, &right, &scale_param) == FAILURE) {
  228. WRONG_PARAM_COUNT;
  229. }
  230. convert_to_long_ex(scale_param);
  231. scale = (int) (Z_LVAL_PP(scale_param) < 0) ? 0 : Z_LVAL_PP(scale_param);
  232. break;
  233. default:
  234. WRONG_PARAM_COUNT;
  235. break;
  236. }
  237. convert_to_string_ex(left);
  238. convert_to_string_ex(right);
  239. bc_init_num(&first TSRMLS_CC);
  240. bc_init_num(&second TSRMLS_CC);
  241. bc_init_num(&result TSRMLS_CC);
  242. php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
  243. php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
  244. bc_multiply (first, second, &result, scale TSRMLS_CC);
  245. if (result->n_scale > scale) {
  246. result->n_scale = scale;
  247. }
  248. Z_STRVAL_P(return_value) = bc_num2str(result);
  249. Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
  250. Z_TYPE_P(return_value) = IS_STRING;
  251. bc_free_num(&first);
  252. bc_free_num(&second);
  253. bc_free_num(&result);
  254. return;
  255. }
  256. /* }}} */
  257. /* {{{ proto string bcdiv(string left_operand, string right_operand [, int scale])
  258. Returns the quotient of two arbitrary precision numbers (division) */
  259. PHP_FUNCTION(bcdiv)
  260. {
  261. zval **left, **right, **scale_param;
  262. bc_num first, second, result;
  263. int scale = BCG(bc_precision);
  264. switch (ZEND_NUM_ARGS()) {
  265. case 2:
  266. if (zend_get_parameters_ex(2, &left, &right) == FAILURE) {
  267. WRONG_PARAM_COUNT;
  268. }
  269. break;
  270. case 3:
  271. if (zend_get_parameters_ex(3, &left, &right, &scale_param) == FAILURE) {
  272. WRONG_PARAM_COUNT;
  273. }
  274. convert_to_long_ex(scale_param);
  275. scale = (int) (Z_LVAL_PP(scale_param) < 0) ? 0 : Z_LVAL_PP(scale_param);
  276. break;
  277. default:
  278. WRONG_PARAM_COUNT;
  279. break;
  280. }
  281. convert_to_string_ex(left);
  282. convert_to_string_ex(right);
  283. bc_init_num(&first TSRMLS_CC);
  284. bc_init_num(&second TSRMLS_CC);
  285. bc_init_num(&result TSRMLS_CC);
  286. php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
  287. php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
  288. switch (bc_divide(first, second, &result, scale TSRMLS_CC)) {
  289. case 0: /* OK */
  290. if (result->n_scale > scale) {
  291. result->n_scale = scale;
  292. }
  293. Z_STRVAL_P(return_value) = bc_num2str(result);
  294. Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
  295. Z_TYPE_P(return_value) = IS_STRING;
  296. break;
  297. case -1: /* division by zero */
  298. php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
  299. break;
  300. }
  301. bc_free_num(&first);
  302. bc_free_num(&second);
  303. bc_free_num(&result);
  304. return;
  305. }
  306. /* }}} */
  307. /* {{{ proto string bcmod(string left_operand, string right_operand)
  308. Returns the modulus of the two arbitrary precision operands */
  309. PHP_FUNCTION(bcmod)
  310. {
  311. zval **left, **right;
  312. bc_num first, second, result;
  313. switch (ZEND_NUM_ARGS()) {
  314. case 2:
  315. if (zend_get_parameters_ex(2, &left, &right) == FAILURE) {
  316. WRONG_PARAM_COUNT;
  317. }
  318. break;
  319. default:
  320. WRONG_PARAM_COUNT;
  321. break;
  322. }
  323. convert_to_string_ex(left);
  324. convert_to_string_ex(right);
  325. bc_init_num(&first TSRMLS_CC);
  326. bc_init_num(&second TSRMLS_CC);
  327. bc_init_num(&result TSRMLS_CC);
  328. bc_str2num(&first, Z_STRVAL_PP(left), 0 TSRMLS_CC);
  329. bc_str2num(&second, Z_STRVAL_PP(right), 0 TSRMLS_CC);
  330. switch (bc_modulo(first, second, &result, 0 TSRMLS_CC)) {
  331. case 0:
  332. Z_STRVAL_P(return_value) = bc_num2str(result);
  333. Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
  334. Z_TYPE_P(return_value) = IS_STRING;
  335. break;
  336. case -1:
  337. php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
  338. break;
  339. }
  340. bc_free_num(&first);
  341. bc_free_num(&second);
  342. bc_free_num(&result);
  343. return;
  344. }
  345. /* }}} */
  346. /* {{{ proto string bcpowmod(string x, string y, string mod [, int scale])
  347. Returns the value of an arbitrary precision number raised to the power of another reduced by a modulous */
  348. PHP_FUNCTION(bcpowmod)
  349. {
  350. char *left, *right, *modulous;
  351. int left_len, right_len, modulous_len;
  352. bc_num first, second, mod, result;
  353. long scale = BCG(bc_precision);
  354. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &left, &left_len, &right, &right_len, &modulous, &modulous_len, &scale) == FAILURE) {
  355. WRONG_PARAM_COUNT;
  356. }
  357. bc_init_num(&first TSRMLS_CC);
  358. bc_init_num(&second TSRMLS_CC);
  359. bc_init_num(&mod TSRMLS_CC);
  360. bc_init_num(&result TSRMLS_CC);
  361. php_str2num(&first, left TSRMLS_CC);
  362. php_str2num(&second, right TSRMLS_CC);
  363. php_str2num(&mod, modulous TSRMLS_CC);
  364. bc_raisemod(first, second, mod, &result, scale TSRMLS_CC);
  365. if (result->n_scale > scale) {
  366. result->n_scale = scale;
  367. }
  368. Z_STRVAL_P(return_value) = bc_num2str(result);
  369. Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
  370. Z_TYPE_P(return_value) = IS_STRING;
  371. bc_free_num(&first);
  372. bc_free_num(&second);
  373. bc_free_num(&mod);
  374. bc_free_num(&result);
  375. return;
  376. }
  377. /* }}} */
  378. /* {{{ proto string bcpow(string x, string y [, int scale])
  379. Returns the value of an arbitrary precision number raised to the power of another */
  380. PHP_FUNCTION(bcpow)
  381. {
  382. zval **left, **right, **scale_param;
  383. bc_num first, second, result;
  384. int scale = BCG(bc_precision);
  385. switch (ZEND_NUM_ARGS()) {
  386. case 2:
  387. if (zend_get_parameters_ex(2, &left, &right) == FAILURE) {
  388. WRONG_PARAM_COUNT;
  389. }
  390. break;
  391. case 3:
  392. if (zend_get_parameters_ex(3, &left, &right, &scale_param) == FAILURE) {
  393. WRONG_PARAM_COUNT;
  394. }
  395. convert_to_long_ex(scale_param);
  396. scale = (int) (Z_LVAL_PP(scale_param) < 0) ? 0 : Z_LVAL_PP(scale_param);
  397. break;
  398. default:
  399. WRONG_PARAM_COUNT;
  400. break;
  401. }
  402. convert_to_string_ex(left);
  403. convert_to_string_ex(right);
  404. bc_init_num(&first TSRMLS_CC);
  405. bc_init_num(&second TSRMLS_CC);
  406. bc_init_num(&result TSRMLS_CC);
  407. php_str2num(&first, Z_STRVAL_PP(left) TSRMLS_CC);
  408. php_str2num(&second, Z_STRVAL_PP(right) TSRMLS_CC);
  409. bc_raise (first, second, &result, scale TSRMLS_CC);
  410. if (result->n_scale > scale) {
  411. result->n_scale = scale;
  412. }
  413. Z_STRVAL_P(return_value) = bc_num2str(result);
  414. Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
  415. Z_TYPE_P(return_value) = IS_STRING;
  416. bc_free_num(&first);
  417. bc_free_num(&second);
  418. bc_free_num(&result);
  419. return;
  420. }
  421. /* }}} */
  422. /* {{{ proto string bcsqrt(string operand [, int scale])
  423. Returns the square root of an arbitray precision number */
  424. PHP_FUNCTION(bcsqrt)
  425. {
  426. zval **left, **scale_param;
  427. bc_num result;
  428. int scale = BCG(bc_precision);
  429. switch (ZEND_NUM_ARGS()) {
  430. case 1:
  431. if (zend_get_parameters_ex(1, &left) == FAILURE) {
  432. WRONG_PARAM_COUNT;
  433. }
  434. break;
  435. case 2:
  436. if (zend_get_parameters_ex(2, &left, &scale_param) == FAILURE) {
  437. WRONG_PARAM_COUNT;
  438. }
  439. convert_to_long_ex(scale_param);
  440. scale = (int) (Z_LVAL_PP(scale_param) < 0) ? 0 : Z_LVAL_PP(scale_param);
  441. break;
  442. default:
  443. WRONG_PARAM_COUNT;
  444. break;
  445. }
  446. convert_to_string_ex(left);
  447. bc_init_num(&result TSRMLS_CC);
  448. php_str2num(&result, Z_STRVAL_PP(left) TSRMLS_CC);
  449. if (bc_sqrt (&result, scale TSRMLS_CC) != 0) {
  450. if (result->n_scale > scale) {
  451. result->n_scale = scale;
  452. }
  453. Z_STRVAL_P(return_value) = bc_num2str(result);
  454. Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
  455. Z_TYPE_P(return_value) = IS_STRING;
  456. } else {
  457. php_error_docref(NULL TSRMLS_CC, E_WARNING, "Square root of negative number");
  458. }
  459. bc_free_num(&result);
  460. return;
  461. }
  462. /* }}} */
  463. /* {{{ proto int bccomp(string left_operand, string right_operand [, int scale])
  464. Compares two arbitrary precision numbers */
  465. PHP_FUNCTION(bccomp)
  466. {
  467. zval **left, **right, **scale_param;
  468. bc_num first, second;
  469. int scale = BCG(bc_precision);
  470. switch (ZEND_NUM_ARGS()) {
  471. case 2:
  472. if (zend_get_parameters_ex(2, &left, &right) == FAILURE) {
  473. WRONG_PARAM_COUNT;
  474. }
  475. break;
  476. case 3:
  477. if (zend_get_parameters_ex(3, &left, &right, &scale_param) == FAILURE) {
  478. WRONG_PARAM_COUNT;
  479. }
  480. convert_to_long_ex(scale_param);
  481. scale = (int) (Z_LVAL_PP(scale_param) < 0) ? 0 : Z_LVAL_PP(scale_param);
  482. break;
  483. default:
  484. WRONG_PARAM_COUNT;
  485. break;
  486. }
  487. convert_to_string_ex(left);
  488. convert_to_string_ex(right);
  489. bc_init_num(&first TSRMLS_CC);
  490. bc_init_num(&second TSRMLS_CC);
  491. bc_str2num(&first, Z_STRVAL_PP(left), scale TSRMLS_CC);
  492. bc_str2num(&second, Z_STRVAL_PP(right), scale TSRMLS_CC);
  493. Z_LVAL_P(return_value) = bc_compare(first, second);
  494. Z_TYPE_P(return_value) = IS_LONG;
  495. bc_free_num(&first);
  496. bc_free_num(&second);
  497. return;
  498. }
  499. /* }}} */
  500. /* {{{ proto bool bcscale(int scale)
  501. Sets default scale parameter for all bc math functions */
  502. PHP_FUNCTION(bcscale)
  503. {
  504. zval **new_scale;
  505. if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &new_scale) == FAILURE) {
  506. WRONG_PARAM_COUNT;
  507. }
  508. convert_to_long_ex(new_scale);
  509. BCG(bc_precision) = (Z_LVAL_PP(new_scale) < 0) ? 0 : Z_LVAL_PP(new_scale);
  510. RETURN_TRUE;
  511. }
  512. /* }}} */
  513. #endif
  514. /*
  515. * Local variables:
  516. * tab-width: 4
  517. * c-basic-offset: 4
  518. * End:
  519. * vim600: sw=4 ts=4 fdm=marker
  520. * vim<600: sw=4 ts=4
  521. */