-
1
- #1
3dlogix
Mechanical
- Jan 31, 2002
- 435
The "floor" and "ceil" relations functions allow you to determine the value of a real number by setting it to its next higher integer or its base integer value. These are little known functions, but can be useful in extracting information.
As an example, the real number parameter "A" is set to 12.5405. In the Relations Editor, the following statements will yield the shown results:
*********
A=12.5405
B=floor(A)
A will be set to 12 (the next lower integer is 12)
*********
A=12.5405
B=ceil(A)
A will be set to 13 (the next higher integer is 13)
*********
A=12.5405
B=floor(A,2)
A will be set to 12.54
*********
A=12.5405
B=ceil(A,2)
A will be set to 12.55
*********
A=12.5405
B=floor(A,3)
A will be set to 12.54 (the "0" is not shown, even though 3 significant digits were indicated)
*********
A=-12.5405
B=ceil(A)
A will be set to -12
*********
A=-12.5405
B=floor(A)
A will be set to -13 (since -13 is "lower" than -12)
A practical example would be to determine the decimal value of a real number. In a part, if d1 equals 24.750, we can write a relation that returns the value after the decimal place.
**********
d1=25.750
DECIMAL=d1-floor(d1)
The DECIMAL parameter will evaluate to .750
Steve
As an example, the real number parameter "A" is set to 12.5405. In the Relations Editor, the following statements will yield the shown results:
*********
A=12.5405
B=floor(A)
A will be set to 12 (the next lower integer is 12)
*********
A=12.5405
B=ceil(A)
A will be set to 13 (the next higher integer is 13)
*********
A=12.5405
B=floor(A,2)
A will be set to 12.54
*********
A=12.5405
B=ceil(A,2)
A will be set to 12.55
*********
A=12.5405
B=floor(A,3)
A will be set to 12.54 (the "0" is not shown, even though 3 significant digits were indicated)
*********
A=-12.5405
B=ceil(A)
A will be set to -12
*********
A=-12.5405
B=floor(A)
A will be set to -13 (since -13 is "lower" than -12)
A practical example would be to determine the decimal value of a real number. In a part, if d1 equals 24.750, we can write a relation that returns the value after the decimal place.
**********
d1=25.750
DECIMAL=d1-floor(d1)
The DECIMAL parameter will evaluate to .750
Steve