In PHP, floating-point data needs to be resolved in a different way.

Source: Internet
Author: User

This article mainly introduces the data in PHP for floating-point type needs to be solved in different ways. Need friends can come to the reference, I hope to help you

Php:bcmath BC is the abbreviation for binary calculator. The arguments for the bc* function are the operands plus an optional [int scale], such as String Bcadd (String $left _operand, String $right _operand[, int $scale]), if scale does not provide , the default value of Bcscale is used.   The large number is directly represented by a string of 0-9, and the result returns a string. Bcadd-adds two high-precision numbers bccomp-compares two high-precision digits, returns-1, 0, 1 bcdiv-divides two high-precision numbers bcmod-the high precision numeric remainder bcmul-multiplies two high-precision numbers bcpow-the high precision number   Word of the bcpowmod-to find High-precision digital exponentiation, number theory is very common bcscale-configure the default decimal places, equivalent to the Linux BC in the "scale=" bcsqrt-to find high-precision digital square root bcsub-subtract two high-precision digits   You can refer to the manual to find out the application of these functions. The code is as follows: The/*bcsub function shows that this function subtracts two high-precision digits, passes in two strings, and subtracts the right operand value from the left side. Scale is an optional option that represents the number of digits required after the  decimal point of the returned value. *//The following code I was guaranteed a decimal point digit $AA =bcsub (134.7,52.5,1); echo $aa;//exit; $BB =bcsub ($aa, 82.2, 1); echo $bb;//exit; Floor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.