Digital functions in crystal report functions

Source: Internet
Author: User
Tags natural logarithm ranges rounds

ABS (x ):
Basic syntax and crystal syntax.
Parameter: X is the number or currency in which you want to return the absolute value.
Return Value: Numeric Value
Operation: ABS (x) returns the absolute value of X.
Example:
ABS (1, 1.50)
1.50 is returned.

ABS (-1, 1.50)
1.50 is returned.

ABS (10-7)
3 is returned.

ABS (7-10)
3 is returned.

Rem basic syntax:
If ABS (37-{file. Field})> 1 then
Formula = "maintenance, temperature check"
End if
// Crystal syntax
If ABS (37-{file. Field})> 1 then
"Maintenance required, please check the temperature"
Else
"";
This example marks an instance with a temperature change of more than ± 1 degree Celsius in the test thermal zone.
 
SGN (number ):
Basic syntax and crystal syntax.
Parameter: number indicates the value of its symbol.
Return Value: 1, 0, or-1.
Operation: SGN returns the symbol of the given number. If number is greater than 0, 1 is returned. If number is 0, 0 is returned. If number is <0,-1 is returned.
The following example applies to basic syntax and crystal Syntax:
SGN (-10)
-1 is returned.

SGN (0)
Returns 0.

SGN (10)
Returns 1.
 
INT (number ):
Basic syntax and crystal syntax.
Parameter: number refers to the value of the nearest integer that you want to forward.
Return Value: integer
Operation: int returns the integer part of a given number by rounding it down to the next smallest integer.
The following example applies to basic syntax and crystal Syntax:
INT (123.678)
123 is returned.

INT (-1, 123.678)
-124 is returned.

INT (-1, 123.1)
-124 is returned.

Note: This function uses functions with the same name as Visual Basic.
The results of fix (N) (or truncate (N) and INT (n) are the same, except when n is negative, in this case, both the fix and truncate return the first integer greater than or equal to N, and the int return the first integer less than or equal to n. For example,
Fix (-1, 10.2)
Truncate (-1, 10.2)
Both return-10.

INT (-1, 10.2)
Returns-11.
For more information, see the fix and truncate functions.
 
Round:
Basic syntax and crystal syntax.
Overload:
Round (X)
Round (x, # places)
Parameter: X is the number or currency to be rounded down. # Places is an integer that represents the number of decimal places X is rounded.
Return: Number

Operation: If the # places parameter is ignored, round is rounded to the nearest integer. If the value to the right of the decimal point is less than or equal to. 499, the program rounds the number to the next minimum number. If the value on the right of the decimal point is equal to or greater than. 5, the program rounding to the next maximum number.
If the # places parameter is used, the value in X is rounded to the nearest decimal place specified by # places. Specifying the # places parameter as 0 is the same as not using the # places parameter. You can also specify a negative number for # places. This number is rounded to the nearest ten, hundreds, or thousands, and so on.
Typical usage: When rounding a value to a specific decimal point is more appropriate than using the original value, you can use the round function at any time.
The following example applies to basic syntax and crystal Syntax:
Round (1.23456)
Returns 1.

Round (1.499)
Returns 1.

Round (1.5000)
Returns 2.

Round (2345.23456, 4)
2345.2346 is returned.

Round (2345.23456, 3)
2345.235 is returned.

Round (2345.23456, 2)
2345.23 is returned.

Round (2345.23456, 0)
2345 is returned.

Round (2345.23456,-1)
2350 is returned.

Round (2345.23456,-2)
2300 is returned.

Round (2345.23456,-3)
2000 is returned.

Round (1.234499, 3)
1.234 is returned.

Round (1.234500, 3)
1.235 is returned.

Round ({file. Amount}, 1)
1854.5 is returned, where amount = 1854.49.

Round ({file. Amount })
1854.00 is returned, where amount = 1854.49.

Round ({file. Amount })
1855.00 is returned, where amount = 1854.51.

Round ({file. Weight}/100)
4 is returned, where Weight = 424.

Round ({file. Weight}/100)
5 is returned, where Weight = 451.

Round (A * B)/C)
11 is returned, where a = 25, B = 3, and c = 7.

Round (file. amount, 1)
1854.5 is returned, where amount = 1854.51.

Round ({file. Wage} * {file. Hours Worked}, 2)
$146.63 is returned, where wage = $5.75 and hours worked = 25.5.

Note: Rounding can also be used as the formatting option for values in a field. You must know that using the field Formatting Function may affect the usage of values in the formula. Refer to the tonumber and to currency operators. For more information, see truncate, fix, INT (number)
 
Roundup:
Basic syntax and crystal syntax.
Overload:
Roundup (X)
Roundup (x, # places)
Parameter: X is the real number to be rounded. # Places is an integer that represents the number of decimal places X is rounded.
Return: Number
Operation: Roundup returns the number rounded up. This function is rounded up (away from zero ).
The following example applies to basic syntax and crystal Syntax:

Roundup (4.1, 0)
Return 5.

Roundup (5.34)
Returns 6.

Roundup (6.36521, 3)
6.366 is returned.

Roundup (-6.36521, 3)
-6.366 is returned.

Roundup (50.43,-1)
Returns 60.

NOTE: If # places is greater than 0 (zero), the number is rounded up to the specified decimal place. If # places is 0 or not specified, the number is rounded up to the next integer; if # places is less than 0, the number is rounded up to the left of the decimal point.
For more information, see round.
 
Truncate:
Truncate and fix are equivalent functions. However, truncate is the first choice in crystal syntax, while fix is the first choice in basic syntax.
Overload:
Truncate (X)
Truncate (x, # places)
Parameter: X is the number or currency to be truncated. # Places is an integer that indicates the number of decimal places to be retained after the value is truncated. (This parameter is optional .)
Return: Number

Operation: truncate (x) returns a decimal or integer by truncating the number from the decimal point. If the # places parameter is specified, the number is truncated to the specified number of decimal places, and the function returns a decimal number. If # places is a negative number, the number is rounded to the first ten or hundreds of digits, and so on.
Typical usage: this function can be used as long as the report or calculation does not require the characters on the Right of decimal places.
The following example applies to basic syntax and crystal Syntax:

Truncate (1.23456)
Returns 1.

Truncate (1.499)
Returns 1.

Truncate (1.599)
Returns 1.

Truncate (1.999)
Returns 1.

Truncate (12346.33, 1)
12346.3 is returned.

Truncate (12345.33,-2)
12300.00 is returned.

If you have 147 golf balls in stock and want to know the number of hits available for sale, the calculation process is 147/12 = 12.25 12.25 (after truncation) = 12, so 12 hits are available for sale. If only the number of hits is used to sell the ball, the cut-off. 25 hits do not matter.
Truncate ({file. Ball inventory}/12)
Return 12, where ball inventory = 147 (147/12 = 12.25, after 12.25 truncation = 12 ).

Truncate ({file. Ball inventory}/12)
Return 12, where ball inventory = 155 (155/12 = 12.92, after 12.92 truncation = 12 ).

Truncate ({file. Ball inventory}/12)
Return 13, where ball inventory = 157 (157/12 = 13.08, 13.08 after truncation = 13 ).

Note: This is not a rounding function. truncate only deletes all characters on the right of the decimal point. For details about rounding, see round.
For truncate (N) and INT (number), when n (number) is negative, truncate returns the first integer greater than or equal to n, int returns the first integer less than or equal to n. In addition, they are meanings. For example,
Truncate (-1, 10.2)
Returns-10.

INT (-1, 10.2)
Returns-11.
Truncation can also be used as a format option for numeric values in a field. The field Formatting Function may affect the use of the value in the formula. For more information about converting to numbers and currencies, see tonumber and to currency operators.
For more information, see int (number)

Mround:
Basic syntax and crystal syntax.
Heavy Load
Mround (X)
Mround (x, multiple)
Parameter: X is the value to be rounded. Multiple is a multiple of the values that you want to round X.
Return: Number

Operation: mround returns the number rounded to a specified multiple. If the remainder of the Division is greater than or equal to half of the X value, this function is rounded up (away from zero ).
The following example applies to basic syntax and crystal Syntax:
Mround (10, 3)
Return 9.

Mround (-10,-3)
Return-9.

Mround (1.3, 0.2)
1.4 is returned.

Mround (5,-2)
Returns 6.

Mround (-5, 2)
-6 is returned.

Note: Crystal Reports ignores the positive and negative numbers of multiples, and the result of the function uses the positive and negative numbers of the first parameter.

Ceiling:
Basic syntax and crystal syntax.
Heavy Load
Ceiling (X)
Ceiling (x, multiple)
Parameter: X is the value to be rounded. Multiple is a multiple of the values that you want to round X.
Return: Number
Operation: ceiling returns the number rounded to a specified multiple. This function is rounded up (away from zero ).
The following example applies to basic syntax and crystal Syntax:
Ceiling (3.5, 1)
4 is returned.

Ceiling (-2.5,-2)
Return Value:-4.

Ceiling (-2.5, 2)
Return Value:-4.

Ceiling (5.43,. 05)
5.45 is returned.

Ceiling (. 43,-1)
Returns 1.

Note: Crystal Reports ignores the positive and negative numbers of multiples, and the function result uses the positive and negative numbers of the first parameter. When the value is adjusted away from the zero pair, always round the value up (not related to the positive and negative signs of the value). If the number is an exact multiple of the multiple, No rounding is performed.

Floor:
Basic syntax and crystal syntax.
Overload:
Floor (X)
Floor (x, multiple)
Parameter: X is the value to be rounded to, and multiple is a multiple of the values to be rounded.
Return: Number
Operation: Floor returns the number rounded to a specified multiple. This function rounds down (away from zero ).
The following example applies to basic syntax and crystal Syntax:
Floor (3.5, 1)
3 is returned.

Floor (-2.5,-2)
Returns-2.

Floor (-2.5, 2)
Returns-2.

Floor (5.43,. 05)
5.40 is returned.

Floor (. 43,-1)
Returns 0.

Note: Crystal Reports ignores the positive and negative numbers of multiples, and the function result uses the positive and negative numbers of the first parameter. When the value is adjusted away from the zero pair, always round the value down (not related to the plus or minus signs of the value). If the number is an exact multiple of the multiple, No rounding is performed.
0 cannot be a multiple parameter. Otherwise, an error occurs. However, floor (0, 0) is allowed and 0 is returned.

Fix:
Fix and truncate are equivalent functions. However, in basic syntax, fix is the first choice, while in crystal syntax, truncate is the first choice.
Overload:
Fix (number)
Fix (number, # places)
Parameter: number indicates the number to be truncated. It can be positive, 0, or negative. # places is an optional number, indicating the number of decimal places to be truncated. If this parameter is omitted, 0 is used.
Return Value: integer, which can be a positive number, 0, or negative number.
Operation: The Fix truncates a number to a specified decimal place and returns it. If # places is omitted, 0 is used.
The following example applies to basic syntax and crystal Syntax:
Fix (1, 123.678)
123 is returned.

Fix (-1, 123.678)
-123 is returned.

Fix (123.678, 1)
123.6 is returned.

Fix (123.678, 2)
123.67 is returned.

Note: The fix function with a single parameter (that is, the fix (number) uses a function with the same name similar to Visual Basic. The Fix (N) and INT (number) Except when n (number) if it is a negative number, the fix returns the first integer greater than or equal to N, and the int returns the first integer less than or equal to N, which has the same effect. For example,
Fix (-1, 10.2)
Returns-10.

INT (-1, 10.2)
Returns-11.

Remainder (Num, denom ):
Basic syntax and crystal syntax.
Parameter: numerator (numerator) is a small value; denominator (denominator) is also a small value.
Return Value: small value
Operation: remainder returns the remainder of the numerator (divisor) divided by the denominator (divisor. In a typical division operation, the program expresses the quotient as an integer (if any) and a maximum of six decimal places. However, when the program uses remainder, it performs Division operations internally, then determines the integer quotient and remainder, and returns only the remainder.

Typical usage: this function can be used for conversion (feet to Miles, pieces to Luo, etc. You can also use it to select a project from an array every n-1 items.
The following example applies to basic syntax and crystal Syntax:
Remainder (12, 5)
Returns 2.

Remainder (16, 5)
Returns 1.

Rem basic syntax
If remainder ({file. Exam #}, 7) = 0 then
Formula = "*****"
End if
// Crystal syntax

If remainder ({file. Exam #}, 7) = 0 then
"*****"
Else
""
This marks every 7 tests for the second party to score.
Totext (truncate ({file. days}/7) + "Week (s)," + totext (remainder ({file. days}, 7) + "day (s )"
Return "9 week (s), 1 day (s )". Converts days to weeks and days. For example, if the value of this field is 64 days, the value returned by the formula is "9 week (s), 1 day (s )".
For more information, see Module (x mod Y)

Sin (number ):
Basic syntax and crystal syntax.
Parameter: the numerical value of the angle in radians.
Return Value: Numeric value between-1 and 1
Operation: sin returns a number that specifies the sine of the angle given by radians. Taking a right triangle as an example, it returns the length of the specified right side of an angle divided by the length of the oblique side.
The following example applies to basic syntax and crystal Syntax:
Sin (1)
Returns 0.8415 (rounded to 4 digits ). The sine of 1 radian.

Sin (30 * crpi/180)
0.5 is returned. This is a sine of 30 degrees. Before calculating the sine, multiply the angle by crpi/180 and convert it to a radian.

Note: This function uses a function similar to Visual Basic with the same name. The value returned by sin ranges from-1 to 1.

Cos (number ):
Basic syntax and crystal syntax.
Parameter: number of degrees in radians.
Return Value: Numeric value between-1 and 1
Operation: cos returns a number that specifies the cosine of the angle given by radians. Taking a right triangle as an example, it returns the length of the specified corner adjacent edge divided by the length of the Oblique Edge.

The following example applies to basic syntax and crystal Syntax:
Cos (1)
Returns 0.5403 (rounded to 4 digits ). This is the cosine of 1 radian.

Cos (60 * crpi/180)
0.5 is returned. This is the cosine of 60 degrees. Before calculating the cosine, multiply the angle by crpi/180 and convert it to a radian.

Note: This function uses functions with the same name as Visual Basic. The value returned by CoS ranges from-1 to 1.

Tan (number ):
Basic syntax and crystal syntax.
Parameter: the numerical value of the angle in radians.
Return Value: Numeric Value
Operation: Tan returns a number that specifies the tangent of the angle given by radians. Taking a right triangle as an example, it returns the length of the specified side of an angle divided by the length of the adjacent side of the angle.
The following example applies to basic syntax and crystal Syntax:
Tan (1)
Returns 1.5574 (rounded to 4 digits ). This is the tangent of 1 radian.

Tan (45 * crpi/180)
Returns 1. This is the tangent of 45 degrees. Before the tangent is calculated, multiply the angle by crpi/180 and convert it to a radian.

Note: This function uses functions with the same name as Visual Basic.

ATN (number ):
Basic syntax and crystal syntax.
Parameter: Numeric Value
Return Value: number of degrees specified by the number of radians
Operation: ATN returns a number that specifies the arc tangent of the given number parameter. In other words, it returns the angle from which the positive tangent is the given numeric parameter.
The following example applies to basic syntax and crystal Syntax:
ATN (1)
Returns the angle of 0.7854 radian (rounded to 4 decimal places ). To convert the angle to degrees, multiply by 180/crpi. For example, ATN (1) * 180/crpi is equal to 45 degrees.

Note: This function uses functions with the same name as Visual Basic. The value returned by ATN ranges from-PI/2 to PI/2 R radians.

Pi:
Basic syntax and crystal syntax.
Returns the mathematical value Pi, which is equal to 3.14 (if rounding to 2 decimal places ).

Sqr (number ):
Basic syntax and crystal syntax.
Parameter: a numeric value greater than or equal to 0.
Return Value: Numeric Value
Operation: sqr returns the square root of a given number.
The following example applies to basic syntax and crystal Syntax:
Sqr (1, 100)
Returns 10.

Note: This function uses functions with the same name as Visual Basic.

Exp (number ):
Basic syntax and crystal syntax.
Parameter: Number of the power.
Return Value: Numeric value.
Operation: EXP returns a number, indicating the power of E (the base of the natural logarithm. E is about 2.718282.
The following example applies to basic syntax and crystal Syntax:
Exp (1, 1.5)
Returns the power of e to 1.5, about 4.48169.

Note: This function uses functions with the same name as Visual Basic. If the given numeric parameter is greater than 705, A number overflow occurs.

Log (number ):
Basic syntax and crystal syntax.
Parameter: Numeric Value
Return Value: Numeric Value
Operation: log returns a number that specifies the natural logarithm of the given number. The natural logarithm is the base logarithm of E, where E is about 2.718282.
The following example applies to basic syntax and crystal Syntax:
Log (1.5)
Returns 0.4055 (rounded to 4 digits ).

Note: This function uses functions with the same name as Visual Basic. When you use the following logic, this function can calculate the logarithm of any value at the bottom:
Loganybase (x, base) = Log (X)/log (base)
(X indicates the number of the logarithm you want to calculate; base indicates the base you want to use .)

For example, for a base-10 logarithm, you enter the following formula text:
Log (X)/log (10)

RND:
Basic syntax and crystal syntax.
Overload:
RND ()
RND (SEED)
Parameter: seed is an optional numeric value parameter.
Return Value: a numeric value.
Operation: RND returns a random number greater than or equal to 0 and less than 1. If seed is equal to 0, RND returns the random number returned from the previous call to RND. If seed is not provided or greater than 0, RND returns the next random number in the internally generated random number sequence. If seed is less than 0, RND uses this seed value to start a new random number sequence and returns the first value in this sequence.

Typical usage: this function is used when the formula requires random numbers (such as statistical calculation or random selection of records to limit the data in the report.

Note: This function is similar to a function of the same name in Visual Basic. You can call RND without specifying the negative seed parameter to enable the new random number sequence. In this case, the program uses the system clock to generate an internal seed. by calling the RND with the negative seed parameter, the program enables the new random number sequence without parameters (or with a positive parameter) the reason for calling RND is that the report looks exactly the same as that in the preview. In other words, it allows you to make full use of random numbers, but the results can be reproduced.

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.