Some methods of handling floating-point numbers in PHP are recorded

Source: Internet
Author: User

Some methods of handling floating-point numbers in PHP are recorded

Do not use the equal sign, greater than, plus, minus, multiply, divide, etc in the program to operate floating-point numbers, and if you need to do this, use the following BC series functions. To ensure accuracy and accuracy.

Two high-precision number comparison sizes
$left_operand$right_operand$scale ] )
  • l e f t = Right returns 0
  • l e f t < Right Returns-1
  • l e f t > Right returns 1
  • $scale the precision to compare, that is, how many digits after the decimal point
Two high-precision numbers added
$left_operand$right_operand$scale ] )
    • Returns several decimals after the $scale is added
Subtract two high-precision numbers
$left_operand$right_operand$scale ] )
    • Returns a few decimals after $scale subtraction
Two high-precision numbers for redundancy/modulus
$left_operand$modulus )
Divide two high-precision numbers
$left_operand$right_operand$scale ] )
    • After dividing $scale, return several decimals
Multiply two high-precision numbers
$left_operand$right_operand$scale ] )
    • Returns several decimals after the $scale is multiplied
The quadratic value of two high-precision numbers
$left_operand$right_operand$scale ] )
    • $scale time, return several decimals
The square root of high precision number
$operand$scale ] )
    • $scale return several decimals
Set the number of decimal places for the BC function
$scale )
    • $scale several decimals

Some methods of handling floating-point numbers in PHP are recorded

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.