spreadsheet_ods_formula/generated/round.rs
1
2use crate::*;
3#[allow(unused_imports)]
4use crate::round::*;
5
6/// Round a number N up to the nearest multiple of the second parameter,
7/// significance.
8///
9/// [documentfoundation->CEILING](https://wiki.documentfoundation.org/Documentation/Calc_Functions/CEILING)
10///
11/// __Syntax__:
12/// ```ods
13/// CEILING( N: Number )
14/// ```
15///
16/// __Constraints__:
17/// Both N and Significance shall be numeric and have the same sign if not 0.
18///
19/// __Semantics__:
20/// Rounds a number up to a multiple of the second number. If Significance is
21/// omitted or an empty parameter (two consecutive ;; semicolons) it is assumed
22/// to be -1 if N is negative and +1 if N is non-negative, making the function
23/// act like the normal mathematical ceiling function if Mode is not given or
24/// zero. If Mode is given and not equal to zero, the absolute value of N is
25/// rounded away from zero to a multiple of the absolute value of Significance
26/// and then the sign applied . If Mode is omitted or zero, rounding is toward
27/// positive infinity; the number is rounded to the smallest multiple of
28/// significance that is equal-to or greater than N. If any of the two
29/// parameters N or Significance is zero, the result is zero.
30///
31/// __Note__:
32/// Many application user interfaces have a CEILING function with only two
33/// parameters, and somewhat different semantics than given here (e.g., they
34/// operate as if there was a non-zero Mode value). These CEILING functions are
35/// inconsistent with the standard mathematical definition of CEILING.
36///
37/// __See also__: [crate::of::floor()], [crate::of::int()], [crate::of::ceiling_()], [crate::of::ceiling__()],
38#[inline]
39pub fn ceiling<A: Number>(n: A) -> FnNumber1<A> {
40 FnNumber1("CEILING", n)
41}
42
43/// Round a number N up to the nearest multiple of the second parameter,
44/// significance.
45///
46/// [documentfoundation->CEILING](https://wiki.documentfoundation.org/Documentation/Calc_Functions/CEILING)
47///
48/// __Syntax__:
49/// ```ods
50/// CEILING( N: Number; Significance: Number )
51/// ```
52///
53/// __Constraints__:
54/// Both N and Significance shall be numeric and have the same sign if not 0.
55///
56/// __Semantics__:
57/// Rounds a number up to a multiple of the second number. If Significance is
58/// omitted or an empty parameter (two consecutive ;; semicolons) it is assumed
59/// to be -1 if N is negative and +1 if N is non-negative, making the function
60/// act like the normal mathematical ceiling function if Mode is not given or
61/// zero. If Mode is given and not equal to zero, the absolute value of N is
62/// rounded away from zero to a multiple of the absolute value of Significance
63/// and then the sign applied . If Mode is omitted or zero, rounding is toward
64/// positive infinity; the number is rounded to the smallest multiple of
65/// significance that is equal-to or greater than N. If any of the two
66/// parameters N or Significance is zero, the result is zero.
67///
68/// __Note__:
69/// Many application user interfaces have a CEILING function with only two
70/// parameters, and somewhat different semantics than given here (e.g., they
71/// operate as if there was a non-zero Mode value). These CEILING functions are
72/// inconsistent with the standard mathematical definition of CEILING.
73///
74/// __See also__: [crate::of::floor()], [crate::of::int()], [crate::of::ceiling()], [crate::of::ceiling__()],
75#[inline]
76pub fn ceiling_<A: Number, B: Number>(n: A, significance: B) -> FnNumber2<A, B> {
77 FnNumber2("CEILING", n, significance)
78}
79
80/// Round a number N up to the nearest multiple of the second parameter,
81/// significance.
82///
83/// [documentfoundation->CEILING](https://wiki.documentfoundation.org/Documentation/Calc_Functions/CEILING)
84///
85/// __Syntax__:
86/// ```ods
87/// CEILING( N: Number; Significance: Number; Mode: Number )
88/// ```
89///
90/// __Constraints__:
91/// Both N and Significance shall be numeric and have the same sign if not 0.
92///
93/// __Semantics__:
94/// Rounds a number up to a multiple of the second number. If Significance is
95/// omitted or an empty parameter (two consecutive ;; semicolons) it is assumed
96/// to be -1 if N is negative and +1 if N is non-negative, making the function
97/// act like the normal mathematical ceiling function if Mode is not given or
98/// zero. If Mode is given and not equal to zero, the absolute value of N is
99/// rounded away from zero to a multiple of the absolute value of Significance
100/// and then the sign applied . If Mode is omitted or zero, rounding is toward
101/// positive infinity; the number is rounded to the smallest multiple of
102/// significance that is equal-to or greater than N. If any of the two
103/// parameters N or Significance is zero, the result is zero.
104///
105/// __Note__:
106/// Many application user interfaces have a CEILING function with only two
107/// parameters, and somewhat different semantics than given here (e.g., they
108/// operate as if there was a non-zero Mode value). These CEILING functions are
109/// inconsistent with the standard mathematical definition of CEILING.
110///
111/// __See also__: [crate::of::floor()], [crate::of::int()], [crate::of::ceiling()], [crate::of::ceiling_()],
112#[inline]
113pub fn ceiling__<A: Number, B: Number>(n: A, significance: B, mode: RoundingMode) -> FnNumber3<A, B, RoundingMode> {
114 FnNumber3("CEILING", n, significance, mode)
115}
116
117/// Rounds a number down to the nearest integer.
118///
119/// [documentfoundation->INT](https://wiki.documentfoundation.org/Documentation/Calc_Functions/INT)
120///
121/// __Syntax__:
122/// ```ods
123/// INT( N: Number )
124/// ```
125///
126/// __Constraints__:
127/// None
128///
129/// __Semantics__:
130/// Returns the nearest integer whose value is less than or equal to N.
131/// Rounding is towards negative infinity.
132///
133/// __See also__: [crate::of::round()], [crate::of::trunc()],
134#[inline]
135pub fn int<A: Number>(n: A) -> FnNumber1<A> {
136 FnNumber1("INT", n)
137}
138
139/// Round a number N down to the nearest multiple of the second parameter,
140/// significance.
141///
142/// [documentfoundation->FLOOR](https://wiki.documentfoundation.org/Documentation/Calc_Functions/FLOOR)
143///
144/// __Syntax__:
145/// ```ods
146/// FLOOR( N: Number )
147/// ```
148///
149/// __Constraints__:
150/// Both N and Significance shall be numeric and have the same sign.
151///
152/// __Semantics__:
153/// Rounds a number down to a multiple of the second number. If Significance is
154/// omitted or an empty parameter (two consecutive ;; semicolons) it is assumed
155/// to be -1 if N is negative and +1 if N is non-negative, making the function
156/// act like the normal mathematical floor function if Mode is not given or
157/// zero. If Mode is given and not equal to zero, the absolute value of N is
158/// rounded toward zero to a multiple of the absolute value of Significance and
159/// then the sign applied . Otherwise, it rounds toward negative infinity, and
160/// the result is the largest multiple of Significance that is less than or
161/// equal to N. If any of the two parameters N or Significance is zero, the
162/// result is zero.
163///
164/// __Note__:
165/// Many application user interfaces have a FLOOR function with only two
166/// parameters, and somewhat different semantics than given here (e.g., they
167/// operate as if there was a non-zero Mode value). These FLOOR functions are
168/// inconsistent with the standard mathematical definition of FLOOR.
169///
170/// __See also__: [crate::of::ceiling()], [crate::of::int()], [crate::of::floor_()], [crate::of::floor__()],
171#[inline]
172pub fn floor<A: Number>(n: A) -> FnNumber1<A> {
173 FnNumber1("FLOOR", n)
174}
175
176/// Round a number N down to the nearest multiple of the second parameter,
177/// significance.
178///
179/// [documentfoundation->FLOOR](https://wiki.documentfoundation.org/Documentation/Calc_Functions/FLOOR)
180///
181/// __Syntax__:
182/// ```ods
183/// FLOOR( N: Number; Significance: Number )
184/// ```
185///
186/// __Constraints__:
187/// Both N and Significance shall be numeric and have the same sign.
188///
189/// __Semantics__:
190/// Rounds a number down to a multiple of the second number. If Significance is
191/// omitted or an empty parameter (two consecutive ;; semicolons) it is assumed
192/// to be -1 if N is negative and +1 if N is non-negative, making the function
193/// act like the normal mathematical floor function if Mode is not given or
194/// zero. If Mode is given and not equal to zero, the absolute value of N is
195/// rounded toward zero to a multiple of the absolute value of Significance and
196/// then the sign applied . Otherwise, it rounds toward negative infinity, and
197/// the result is the largest multiple of Significance that is less than or
198/// equal to N. If any of the two parameters N or Significance is zero, the
199/// result is zero.
200///
201/// __Note__:
202/// Many application user interfaces have a FLOOR function with only two
203/// parameters, and somewhat different semantics than given here (e.g., they
204/// operate as if there was a non-zero Mode value). These FLOOR functions are
205/// inconsistent with the standard mathematical definition of FLOOR.
206///
207/// __See also__: [crate::of::ceiling()], [crate::of::int()], [crate::of::floor()], [crate::of::floor__()],
208#[inline]
209pub fn floor_<A: Number, B: Number>(n: A, significance: B) -> FnNumber2<A, B> {
210 FnNumber2("FLOOR", n, significance)
211}
212
213/// Round a number N down to the nearest multiple of the second parameter,
214/// significance.
215///
216/// [documentfoundation->FLOOR](https://wiki.documentfoundation.org/Documentation/Calc_Functions/FLOOR)
217///
218/// __Syntax__:
219/// ```ods
220/// FLOOR( N: Number; Significance: Number; Mode: Number )
221/// ```
222///
223/// __Constraints__:
224/// Both N and Significance shall be numeric and have the same sign.
225///
226/// __Semantics__:
227/// Rounds a number down to a multiple of the second number. If Significance is
228/// omitted or an empty parameter (two consecutive ;; semicolons) it is assumed
229/// to be -1 if N is negative and +1 if N is non-negative, making the function
230/// act like the normal mathematical floor function if Mode is not given or
231/// zero. If Mode is given and not equal to zero, the absolute value of N is
232/// rounded toward zero to a multiple of the absolute value of Significance and
233/// then the sign applied . Otherwise, it rounds toward negative infinity, and
234/// the result is the largest multiple of Significance that is less than or
235/// equal to N. If any of the two parameters N or Significance is zero, the
236/// result is zero.
237///
238/// __Note__:
239/// Many application user interfaces have a FLOOR function with only two
240/// parameters, and somewhat different semantics than given here (e.g., they
241/// operate as if there was a non-zero Mode value). These FLOOR functions are
242/// inconsistent with the standard mathematical definition of FLOOR.
243///
244/// __See also__: [crate::of::ceiling()], [crate::of::int()], [crate::of::floor()], [crate::of::floor_()],
245#[inline]
246pub fn floor__<A: Number, B: Number>(n: A, significance: B, mode: RoundingMode) -> FnNumber3<A, B, RoundingMode> {
247 FnNumber3("FLOOR", n, significance, mode)
248}
249
250/// Rounds the number to given multiple.
251///
252/// [documentfoundation->MROUND](https://wiki.documentfoundation.org/Documentation/Calc_Functions/MROUND)
253///
254/// __Syntax__:
255/// ```ods
256/// MROUND( A: Number; B: Number )
257/// ```
258///
259/// __Constraints__:
260/// None
261///
262/// __Semantics__:
263/// Returns the number X, for which the following holds: X/B = INT(X / B) (B
264/// divides X), and for any other Y with the same property, ABS(Y – A) ≥
265/// ABS(X - A). In case that two such X exist, the greater one is the result.
266/// In less formal language, this function rounds the number A to multiples of
267/// B.
268///
269/// __See also__: [crate::of::abs()], [crate::of::int()], [crate::of::round()],
270#[inline]
271pub fn mround<A: Number, B: Number>(a: A, b: B) -> FnNumber2<A, B> {
272 FnNumber2("MROUND", a, b)
273}
274
275/// Rounds the value X to the nearest multiple of the power of 10 specified by
276/// Digits.
277///
278/// [documentfoundation->ROUND](https://wiki.documentfoundation.org/Documentation/Calc_Functions/ROUND)
279///
280/// __Syntax__:
281/// ```ods
282/// ROUND( X: Number )
283/// ```
284///
285/// __Constraints__:
286/// None
287///
288/// __Semantics__:
289/// Round number X to the precision specified by Digits. The number X is
290/// rounded to the nearest power of 10 given by 10 −Digits. If Digits is
291/// zero, or absent, round to the nearest decimal integer. If Digits is
292/// non-negative, round to the specified number of decimal places. If Digits is
293/// negative, round to the left of the decimal point by -Digits places. If X is
294/// halfway between the two nearest values, the result shall round away from
295/// zero. Note that if X is a Number, and Digits ≤ 0, the results will always
296/// be an integer (without a fractional component).
297///
298/// __See also__: [crate::of::trunc()], [crate::of::int()], [crate::of::round_()],
299#[inline]
300pub fn round<A: Number>(x: A) -> FnNumber1<A> {
301 FnNumber1("ROUND", x)
302}
303
304/// Rounds the value X to the nearest multiple of the power of 10 specified by
305/// Digits.
306///
307/// [documentfoundation->ROUND](https://wiki.documentfoundation.org/Documentation/Calc_Functions/ROUND)
308///
309/// __Syntax__:
310/// ```ods
311/// ROUND( X: Number; Digits: Number )
312/// ```
313///
314/// __Constraints__:
315/// None
316///
317/// __Semantics__:
318/// Round number X to the precision specified by Digits. The number X is
319/// rounded to the nearest power of 10 given by 10 −Digits. If Digits is
320/// zero, or absent, round to the nearest decimal integer. If Digits is
321/// non-negative, round to the specified number of decimal places. If Digits is
322/// negative, round to the left of the decimal point by -Digits places. If X is
323/// halfway between the two nearest values, the result shall round away from
324/// zero. Note that if X is a Number, and Digits ≤ 0, the results will always
325/// be an integer (without a fractional component).
326///
327/// __See also__: [crate::of::trunc()], [crate::of::int()], [crate::of::round()],
328#[inline]
329pub fn round_<A: Number, B: Number>(x: A, digits: B) -> FnNumber2<A, B> {
330 FnNumber2("ROUND", x, digits)
331}
332
333/// Rounds the value X towards zero to the number of digits specified by
334/// Digits.
335///
336/// [documentfoundation->ROUNDDOWN](https://wiki.documentfoundation.org/Documentation/Calc_Functions/ROUNDDOWN)
337///
338/// __Syntax__:
339/// ```ods
340/// ROUNDDOWN( X: Number )
341/// ```
342///
343/// __Constraints__:
344/// None
345///
346/// __Semantics__:
347/// Round X towards zero, to the precision specified by Digits. The number
348/// returned is a multiple of 10−Digits. If Digits is zero, or absent, round
349/// to the largest decimal integer whose absolute value is smaller or equal to
350/// the absolute value of X. If Digits is positive, round towards zero to the
351/// specified number of decimal places. If Digits is negative, round towards
352/// zero to the left of the decimal point by -Digits places.
353///
354/// __See also__: [crate::of::trunc()], [crate::of::int()], [crate::of::round()], [crate::of::roundup()], [crate::of::rounddown_()],
355#[inline]
356pub fn rounddown<A: Number>(x: A) -> FnNumber1<A> {
357 FnNumber1("ROUNDDOWN", x)
358}
359
360/// Rounds the value X towards zero to the number of digits specified by
361/// Digits.
362///
363/// [documentfoundation->ROUNDDOWN](https://wiki.documentfoundation.org/Documentation/Calc_Functions/ROUNDDOWN)
364///
365/// __Syntax__:
366/// ```ods
367/// ROUNDDOWN( X: Number; Digits: Integer )
368/// ```
369///
370/// __Constraints__:
371/// None
372///
373/// __Semantics__:
374/// Round X towards zero, to the precision specified by Digits. The number
375/// returned is a multiple of 10−Digits. If Digits is zero, or absent, round
376/// to the largest decimal integer whose absolute value is smaller or equal to
377/// the absolute value of X. If Digits is positive, round towards zero to the
378/// specified number of decimal places. If Digits is negative, round towards
379/// zero to the left of the decimal point by -Digits places.
380///
381/// __See also__: [crate::of::trunc()], [crate::of::int()], [crate::of::round()], [crate::of::roundup()], [crate::of::rounddown()],
382#[inline]
383pub fn rounddown_<A: Number, B: Number>(x: A, digits: B) -> FnNumber2<A, B> {
384 FnNumber2("ROUNDDOWN", x, digits)
385}
386
387/// Rounds the value X away from zero to the number of digits specified by
388/// Digits
389///
390/// [documentfoundation->ROUNDUP](https://wiki.documentfoundation.org/Documentation/Calc_Functions/ROUNDUP)
391///
392/// __Syntax__:
393/// ```ods
394/// ROUNDUP( X: Number )
395/// ```
396///
397/// __Constraints__:
398/// None
399///
400/// __Semantics__:
401/// Round X away from zero, to the precision specified by Digits. The number
402/// returned is a multiple of 10−Digits. If Digits is zero, or absent, round
403/// to the smallest decimal integer whose absolute value is larger or equal to
404/// the absolute value of X. If Digits is positive, round away from zero to the
405/// specified number of decimal places. If Digits is negative, round away from
406/// zero to the left of the decimal point by -Digits places.
407///
408/// __See also__: [crate::of::trunc()], [crate::of::int()], [crate::of::round()], [crate::of::rounddown()], [crate::of::roundup_()],
409#[inline]
410pub fn roundup<A: Number>(x: A) -> FnNumber1<A> {
411 FnNumber1("ROUNDUP", x)
412}
413
414/// Rounds the value X away from zero to the number of digits specified by
415/// Digits
416///
417/// [documentfoundation->ROUNDUP](https://wiki.documentfoundation.org/Documentation/Calc_Functions/ROUNDUP)
418///
419/// __Syntax__:
420/// ```ods
421/// ROUNDUP( X: Number; Digits: Integer )
422/// ```
423///
424/// __Constraints__:
425/// None
426///
427/// __Semantics__:
428/// Round X away from zero, to the precision specified by Digits. The number
429/// returned is a multiple of 10−Digits. If Digits is zero, or absent, round
430/// to the smallest decimal integer whose absolute value is larger or equal to
431/// the absolute value of X. If Digits is positive, round away from zero to the
432/// specified number of decimal places. If Digits is negative, round away from
433/// zero to the left of the decimal point by -Digits places.
434///
435/// __See also__: [crate::of::trunc()], [crate::of::int()], [crate::of::round()], [crate::of::rounddown()], [crate::of::roundup()],
436#[inline]
437pub fn roundup_<A: Number, B: Number>(x: A, digits: B) -> FnNumber2<A, B> {
438 FnNumber2("ROUNDUP", x, digits)
439}
440
441/// Truncate a number to a specified number of digits.
442///
443/// [documentfoundation->TRUNC](https://wiki.documentfoundation.org/Documentation/Calc_Functions/TRUNC)
444///
445/// __Syntax__:
446/// ```ods
447/// TRUNC( A: Number; B: Integer )
448/// ```
449///
450/// __Constraints__:
451/// None
452///
453/// __Semantics__:
454/// Truncate number A to the number of digits specified by B. If B is zero, or
455/// absent, truncate to an integer. If B is positive, truncate to the specified
456/// number of decimal places. If B is negative, truncate to the left of the
457/// decimal point.
458///
459/// __See also__: [crate::of::round()], [crate::of::int()],
460#[inline]
461pub fn trunc<A: Number, B: Number>(a: A, b: B) -> FnNumber2<A, B> {
462 FnNumber2("TRUNC", a, b)
463}