search
HomeCommon ProblemWhat does round function mean?

What does round function mean?

Apr 24, 2024 pm 01:51 PM
git

ROUND function rounds a number to a specified number of digits. Usage: ROUND(number, num_digits), where number is the target number, num_digits is the number of rounding digits, positive values ​​are rounded to the right, and negative values ​​are rounded to the left. Steps: 1. Divide by 10 to the power of num_digits; 2. Round according to the rules; 3. Multiply by 10 to the power of num_digits.

What does round function mean?

Meaning of ROUND function

The ROUND function is used to round a number to a specified number of digits.

Syntax

<code>ROUND(number, num_digits)</code>

Parameters

    ##number: The number to be rounded.
  • num_digits: Number of digits to round to. Negative values ​​round to the left, positive values ​​round to the right.

Working principle

ROUND function works through the following steps:

    Divide number by 10 raised to the num_digits power to get an intermediate result.
  1. If the decimal part of the intermediate result is greater than or equal to 0.5 (for right rounding) or less than 0.5 (for left rounding), then the intermediate result is rounded to the nearest integer.
  2. Multiply the rounded integer by 10 raised to the num_digits power to get the final result.

Example

    ROUND(123.45, 0) returns 123 (rounded to the left to an integer)
  • ROUND(123.45, 1) Returns 123.5 (rounded to the right to one decimal place)
  • ROUND(123.45, -1) Returns 120 (rounded to the left to the tenth place)

The above is the detailed content of What does round function mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor