# Mathematical functions in System

Source: Internet
Author: User
This page has been updated to the public function directory under the System Unit.
```// Absolute value: absvar D: real; V: variant; begin D: = ABS (-1.2); showmessage (floattostr (d); {1.2} V: = '-100'; showmessage (V); {-100; V is a variant type without conversion} V: = ABS (V); showmessage (V); {100; if the variable is indeed a number, the variant type can also take the absolute value} end;

// Return INTEGER: trunc, round, intvar I: integer; D: real; begin I: = trunc (1234.5678); {truncation} showmessage (inttostr (I )); {1234} I: = round (1234.5678); {rounding} showmessage (inttostr (I); {1235} {BOTH int and trunc are rounded to 0, but the int returned is not an integer type} D: = int (-1234.5678); showmessage (floattostr (d); {-1234} end;

// Square: sqr var D: real; begin D: = sqr (6); showmessage (floattostr (d); {36} end;

// Square root: SQRT var D: real; begin D: = SQRT (81); showmessage (floattostr (d); {9} end;

// Judge whether an integer is an odd number: oddvar I: integer; B: Boolean; begin I: = 11; B: = odd (I ); {returns an odd number} showmessage (booltostr (B); {true} I: = 12; B: = odd (I); showmessage (booltostr (B )); {false} end;

```
Related Keywords:

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.