Numeric function [MySQL][database]

Numeric function

Here we divide it into several parts:

Part 1: Basic Functions

  1. ABS(x)

    • returns the absolute value of x
  2. SIGN(x)

    • Returns the sign of x, 1 if it is positive, -1 if it is negative, 0 if it is 0
  3. PI()

    • Returns the value of pi
  4. CEIL(x) (or CEILING(x))

    • Improvement arrangement
    • This function is also called: ceiling function
  5. FLOOR(X)

    • round down
    • This function is also called: floor function
  6. LEAST(e1,e2,e3,e4,…)j

    • Returns the smallest value in the list
    • We talked about this before when we talked about non-symbolic operators, we said at the time that this is also a function
  7. CREATEST(e1,e2,e3,…)

    • Returns the largest value in the list
    • We also talked about this function when we talked about non-symbolic operators before.
  8. MOD (x, y)

    • Returns the remainder after dividing x by y
  9. RAND()

    • Returns a random value of 0 - 1
  10. RAND(x)

    • Returns a random value of 0 - 1, where the value of x is used as the seed value, the same seed value will produce the same random number
      • Note here: If it is a real random number, we cannot control the random value, but it can be controlled here, indicating that this is a pseudo-random number
  11. ROUND(x)

    • rounding
  12. ROUND(x,y)

    • Round up and round to y digits after the decimal point
  13. TRUNCATE(x,y)

    • Returns the result of a number x truncated to y with y decimal places
    • In addition to being a function, TRUNCATE is also a keyword used to clear the data table
  14. SQRT(x)

    • returns the square root of x
    • Note: When the value of x is negative, return NULL

Part 2: Angle and Radian Interchange Functions

  1. RADIANS(x)

    • Convert the angle to radians, where the parameter x is the angle value
  2. DEGREES(x)

    • Convert the radian to the angle, where the parameter x is the radian system
  • The meaning of radians here is the meaning of radians
  • The meaning of degrees here is the meaning of angle

Part 3: Trigonometry

  1. SIN(x)

    • Returns the sine of x, where the parameter x is in radians
    • So if we know an angle, we need to convert the angle to radian first, and then pass the radian into the parameter
  2. ASIN(x)

    • Returns the arcsine of x, which is the value whose sine is x
    • Because our sine value can only be between -1 - 1, so if the value of x is not between -1 and 1, return null
  3. COS(x)

    • returns the cosine of x
    • The parameter x here is also in radians
      • If we know an angle, this time we first convert the angle to radians
  4. SO(x)

    • Returns the tangent of x
    • Here the parameter x is also in radians ()
      • Here is also if we know an angle, at this time we have to convert the angle to radian first
  5. ATAN (x)

    • Returns the arc tangent of x, that is, returns the value whose tangent is x
    • Because our tangent can be between negative infinity and positive infinity, there is no limit to the parameter x here
  6. ATAN2 (m, n)

    • Returns the arctangent of the two arguments

    • What is the arc tangent of returning two arguments?

      • Here we talk about what the ANTO2(m,n) function does and how to use it?

        The ATAN2(M,N) function returns the arc tangent of two parameters. Compared with the ATAN(x) function, ATAN(M,N) requires two parameters, for example, there are two points point(x1,y1) and point( x, y), if the ATAN(x) function is used to calculate the arc tangent, it is ATAN((y2-y1)/(x2-x1)), and if the ATAN2(m, n) function is used to calculate the arc tangent, it is ATAN( y2-y1,x2-x1)

        • It can be seen from the way of use that when x2 - x1 is 0, an error will be reported if the ATAN(x) function is used, while the ATAN2(m,n) function can be used to calculate

Part 4: Exponentials and Logarithms

  1. POW(x,y) (or POWER(x,y))

    • returns x raised to the y power
  2. EXP(x)

    • Returns e raised to the power x, where e is a constant (2.718281828459045)
  3. LN(x) (or LOG(x))

    • Returns the logarithm of x to the base e
    • When x<=0, the returned result is null
  4. LOG10(x)

    • Returns the base 10 logarithm of x
    • When x<=0, the return result is null
  5. LOG2(x)

    • Returns the base 2 logarithm of x
    • When x<=0, the return result is null

Part 5: Functions for converting between bases

  1. BIN(x)

    • Returns the binary form of x
  2. HEX(x)

    • Returns the hexadecimal form of x
  3. OCT(x)

    • Returns the octal form of x
  4. CONV(x,f1,f2)

    • Return x in f1 base into f2 base form

おすすめ

転載: blog.csdn.net/m0_57001006/article/details/123649363