Embedded Template Library 1.0
Loading...
Searching...
No Matches
rounded_integral_division.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2025 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining numerator
13copy of this software and associated documentation files(the "Software"), to
14deal in the Software without restriction, including without limitation the
15rights to use, copy, modify, merge, publish, distribute, sublicense, and / or
16sell copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_ROUNDED_INTEGRAL_DIVISION_INCLUDED
32#define ETL_ROUNDED_INTEGRAL_DIVISION_INCLUDED
33
34#include "platform.h"
35#include "absolute.h"
36#include "type_traits.h"
37#include "utility.h"
38
39namespace etl
40{
41 namespace private_rounded_integral_division
42 {
43 //*****************************************************************************
44 // Checks if two values have the same sign.
45 // For signed integral types.
46 //*****************************************************************************
47 template <typename T>
48 ETL_CONSTEXPR typename etl::enable_if< etl::is_integral<T>::value && etl::is_signed<T>::value, bool>::type are_same_sign(T a, T b) ETL_NOEXCEPT
49 {
50 return ((a ^ b) >= 0);
51 }
52
53 //*****************************************************************************
54 // Checks if two values have the same sign.
55 // For unsigned integral types.
56 //*****************************************************************************
57 template <typename T>
58 ETL_CONSTEXPR typename etl::enable_if< etl::is_integral<T>::value && etl::is_unsigned<T>::value, bool>::type are_same_sign(T /*a*/, T /*b*/)
59 ETL_NOEXCEPT
60 {
61 return true;
62 }
63 } // namespace private_rounded_integral_division
64
65 //***************************************************************************
72 //***************************************************************************
73 template <typename T>
74 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_signed<T>::value, T>::type divide_round_to_ceiling(T numerator,
75 T denominator)
76 ETL_NOEXCEPT
77 {
78 const T remainder = numerator % denominator;
79 const T quotient = numerator / denominator;
80
81 // If remainder is zero, already exact
82 if (remainder == 0)
83 {
84 return quotient;
85 }
86
87 // If signs are the same, increment quotient
88 return private_rounded_integral_division::are_same_sign(numerator, denominator) ? quotient + 1 : quotient;
89 }
90
91 //***************************************************************************
99 //***************************************************************************
100 template <typename T1, typename T2>
101 ETL_CONSTEXPR14
102 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_signed<T1>::value && etl::is_signed<T2>::value,
103 typename etl::common_type<T1, T2>::type>::type
104 divide_round_to_ceiling(T1 numerator, T2 denominator) ETL_NOEXCEPT
105 {
106 typedef typename etl::common_type<T1, T2>::type type;
107
108 return divide_round_to_ceiling(static_cast<type>(numerator), static_cast<type>(denominator));
109 }
110
111 //***************************************************************************
118 //***************************************************************************
119 template <typename T>
120 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_unsigned<T>::value, T>::type divide_round_to_ceiling(T numerator,
121 T denominator)
122 ETL_NOEXCEPT
123 {
124 const T remainder = numerator % denominator;
125 const T quotient = numerator / denominator;
126
127 // If remainder is zero, already exact, otherwise, increment quotient
128 return remainder == 0U ? quotient : quotient + 1U;
129 }
130
131 //***************************************************************************
139 //***************************************************************************
140 template <typename T1, typename T2>
141 ETL_CONSTEXPR14
142 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_unsigned<T1>::value && etl::is_unsigned<T2>::value,
143 typename etl::common_type<T1, T2>::type>::type
144 divide_round_to_ceiling(T1 numerator, T2 denominator) ETL_NOEXCEPT
145 {
146 typedef typename etl::common_type<T1, T2>::type type;
147
148 return divide_round_to_ceiling(static_cast<type>(numerator), static_cast<type>(denominator));
149 }
150
151 //***************************************************************************
158 //***************************************************************************
159 template <typename T>
160 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_signed<T>::value, T>::type divide_round_to_floor(T numerator,
161 T denominator)
162 ETL_NOEXCEPT
163 {
164 const T remainder = numerator % denominator;
165 const T quotient = numerator / denominator;
166
167 // If remainder is zero, already exact
168 if (remainder == 0)
169 {
170 return quotient;
171 }
172
173 // If signs are different, decrement quotient
174 return private_rounded_integral_division::are_same_sign(numerator, denominator) ? quotient : quotient - 1;
175 }
176
177 //***************************************************************************
185 //***************************************************************************
186 template <typename T1, typename T2>
187 ETL_CONSTEXPR14
188 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_signed<T1>::value && etl::is_signed<T2>::value,
189 typename etl::common_type<T1, T2>::type>::type
190 divide_round_to_floor(T1 numerator, T2 denominator) ETL_NOEXCEPT
191 {
192 typedef typename etl::common_type<T1, T2>::type type;
193
194 return divide_round_to_floor(static_cast<type>(numerator), static_cast<type>(denominator));
195 }
196
197 //***************************************************************************
204 //***************************************************************************
205 template <typename T>
206 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_unsigned<T>::value, T>::type divide_round_to_floor(T numerator,
207 T denominator)
208 ETL_NOEXCEPT
209 {
210 return numerator / denominator;
211 }
212
213 //***************************************************************************
222 template <typename T1, typename T2>
223 ETL_CONSTEXPR14
224 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_unsigned<T1>::value && etl::is_unsigned<T2>::value,
225 typename etl::common_type<T1, T2>::type>::type
226 divide_round_to_floor(T1 numerator, T2 denominator) ETL_NOEXCEPT
227 {
228 typedef typename etl::common_type<T1, T2>::type type;
229
230 const type common_numerator = numerator;
231 const type common_denominator = denominator;
232
233 return common_numerator / common_denominator;
234 }
235
236 //***************************************************************************
243 //***************************************************************************
244 template <typename T>
245 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_signed<T>::value, T>::type divide_round_to_infinity(T numerator,
246 T denominator)
247 ETL_NOEXCEPT
248 {
249 const T remainder = numerator % denominator;
250 const T quotient = numerator / denominator;
251
252 if (private_rounded_integral_division::are_same_sign(numerator, denominator))
253 {
254 // Same sign, round towards +infinity
255 return (remainder != 0) ? quotient + 1 : quotient;
256 }
257 else
258 {
259 // Different signs, round towards -infinity
260 return (remainder != 0) ? quotient - 1 : quotient;
261 }
262 }
263
264 //***************************************************************************
272 //***************************************************************************
273 template <typename T1, typename T2>
274 ETL_CONSTEXPR14
275 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_signed<T1>::value && etl::is_signed<T2>::value,
276 typename etl::common_type<T1, T2>::type>::type
277 divide_round_to_infinity(T1 numerator, T2 denominator) ETL_NOEXCEPT
278 {
279 typedef typename etl::common_type<T1, T2>::type type;
280
281 return divide_round_to_infinity(static_cast<type>(numerator), static_cast<type>(denominator));
282 }
283
284 //***************************************************************************
291 //***************************************************************************
292 template <typename T>
293 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_unsigned<T>::value, T>::type
294 divide_round_to_infinity(T numerator, T denominator) ETL_NOEXCEPT
295 {
296 const T remainder = numerator % denominator;
297 const T quotient = numerator / denominator;
298
299 return remainder ? quotient + 1U : quotient;
300 }
301
302 //***************************************************************************
310 //***************************************************************************
311 template <typename T1, typename T2>
312 ETL_CONSTEXPR14
313 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_unsigned<T1>::value && etl::is_unsigned<T2>::value,
314 typename etl::common_type<T1, T2>::type>::type
315 divide_round_to_infinity(T1 numerator, T2 denominator) ETL_NOEXCEPT
316 {
317 typedef typename etl::common_type<T1, T2>::type type;
318
319 return divide_round_to_infinity(static_cast<type>(numerator), static_cast<type>(denominator));
320 }
321
322 //***************************************************************************
329 //***************************************************************************
330 template <typename T>
331 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_unsigned<T>::value, T>::type divide_round_to_zero(T numerator,
332 T denominator)
333 ETL_NOEXCEPT
334 {
335 return numerator / denominator;
336 }
337
338 //***************************************************************************
346 //***************************************************************************
347 template <typename T1, typename T2>
348 ETL_CONSTEXPR14 typename etl::enable_if<etl::is_integral<T1>::value && etl::is_integral<T2>::value, typename etl::common_type<T1, T2>::type>::type
349 divide_round_to_zero(T1 numerator, T2 denominator) ETL_NOEXCEPT
350 {
351 typedef typename etl::common_type<T1, T2>::type type;
352
353 // Cast to common type to avoid overflow.
354 const type common_numerator = numerator;
355 const type common_denominator = denominator;
356
357 return common_numerator / common_denominator;
358 }
359
360 //***************************************************************************
367 //***************************************************************************
368 template <typename T>
369 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_signed<T>::value, T>::type divide_round_half_up(T numerator,
370 T denominator)
371 ETL_NOEXCEPT
372 {
373 // Normal division
374 const T remainder = numerator % denominator;
375 const T quotient = numerator / denominator;
376
377 // Work with magnitudes in unsigned form (avoids abs() overflow)
378 typedef typename etl::make_unsigned<T>::type utype;
379 utype abs_remainder = remainder < 0 ? utype(0) - utype(remainder) : utype(remainder);
380 utype abs_denominator = denominator < 0 ? utype(0) - utype(denominator) : utype(denominator);
381
382 // Threshold for rounding up (half the denominatorominator, rounded up)
383 utype half_denominator = (abs_denominator + 1) / 2;
384
385 if (abs_remainder >= half_denominator)
386 {
387 // Round away from zero
388 if (private_rounded_integral_division::are_same_sign(numerator, denominator))
389 {
390 return quotient + 1; // same sign ? increment
391 }
392 else
393 {
394 return quotient - 1; // different sign ? decrement
395 }
396 }
397
398 return quotient;
399 }
400
401 //***************************************************************************
409 //***************************************************************************
410 template <typename T1, typename T2>
411 ETL_CONSTEXPR14
412 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_signed<T1>::value && etl::is_signed<T2>::value,
413 typename etl::common_type<T1, T2>::type>::type
414 divide_round_half_up(T1 numerator, T2 denominator) ETL_NOEXCEPT
415 {
416 typedef typename etl::common_type<T1, T2>::type type;
417
418 return divide_round_half_up(static_cast<type>(numerator), static_cast<type>(denominator));
419 }
420
421 //***************************************************************************
428 //***************************************************************************
429 template <typename T>
430 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_unsigned<T>::value, T>::type divide_round_half_up(T numerator,
431 T denominator)
432 ETL_NOEXCEPT
433 {
434 const T remainder = numerator % denominator;
435 const T quotient = numerator / denominator;
436
437 // If remainder is at least half the divisor, round up
438 return (remainder >= (denominator / 2U) + (denominator % 2U)) ? quotient + 1U : quotient;
439 }
440
441 //***************************************************************************
449 //***************************************************************************
450 template <typename T1, typename T2>
451 ETL_CONSTEXPR14
452 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_unsigned<T1>::value && etl::is_unsigned<T2>::value,
453 typename etl::common_type<T1, T2>::type>::type
454 divide_round_half_up(T1 numerator, T2 denominator) ETL_NOEXCEPT
455 {
456 typedef typename etl::common_type<T1, T2>::type type;
457
458 return divide_round_half_up(static_cast<type>(numerator), static_cast<type>(denominator));
459 }
460
461 //***************************************************************************
468 //***************************************************************************
469 template <typename T>
470 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_signed<T>::value, T>::type divide_round_half_down(T numerator,
471 T denominator)
472 ETL_NOEXCEPT
473 {
474 const T quotient = numerator / denominator;
475 const T remainder = numerator % denominator;
476
477 typedef typename etl::make_unsigned<T>::type utype;
478 const utype abs_denominator = etl::absolute_unsigned(denominator);
479 const utype abs_remainder = etl::absolute_unsigned(remainder);
480
481 // Direction: +1 if result should be more positive, -1 if more negative
482 const T direction = private_rounded_integral_division::are_same_sign(numerator, denominator) ? 1 : -1;
483
484 // Only round away from zero if remainder is strictly greater than half the
485 // divisor
486 return abs_remainder > (abs_denominator / 2U) ? quotient + direction : quotient;
487 }
488
489 //***************************************************************************
497 //***************************************************************************
498 template <typename T1, typename T2>
499 ETL_CONSTEXPR14
500 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_signed<T1>::value && etl::is_signed<T2>::value,
501 typename etl::common_type<T1, T2>::type>::type
502 divide_round_half_down(T1 numerator, T2 denominator) ETL_NOEXCEPT
503 {
504 typedef typename etl::common_type<T1, T2>::type type;
505
506 return divide_round_half_down(static_cast<type>(numerator), static_cast<type>(denominator));
507 }
508
509 //***************************************************************************
516 //***************************************************************************
517 template <typename T>
518 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_unsigned<T>::value, T>::type divide_round_half_down(T numerator,
519 T denominator)
520 ETL_NOEXCEPT
521 {
522 const T remainder = numerator % denominator;
523 const T quotient = numerator / denominator;
524
525 // If remainder is at least half the divisor, round down
526 return (remainder > (denominator / 2U)) ? quotient + 1U : quotient;
527 }
528
529 //***************************************************************************
537 //***************************************************************************
538 template <typename T1, typename T2>
539 ETL_CONSTEXPR14
540 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_unsigned<T1>::value && etl::is_unsigned<T2>::value,
541 typename etl::common_type<T1, T2>::type>::type
542 divide_round_half_down(T1 numerator, T2 denominator) ETL_NOEXCEPT
543 {
544 typedef typename etl::common_type<T1, T2>::type type;
545
546 return divide_round_half_down(static_cast<type>(numerator), static_cast<type>(denominator));
547 }
548
549 //***************************************************************************
556 //***************************************************************************
557 template <typename T>
558 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_signed<T>::value, T>::type divide_round_half_even(T numerator,
559 T denominator)
560 ETL_NOEXCEPT
561 {
562 const T quotient = numerator / denominator;
563 const T remainder = numerator % denominator;
564 const T direction = ((numerator >= 0) == (denominator >= 0)) ? 1 : -1;
565
566 // Work with magnitudes in unsigned form (avoids abs() overflow for
567 // T::min()).
568 typedef typename std::make_unsigned<T>::type utype;
569 const utype abs_denominator = (denominator < 0) ? (utype(0) - utype(denominator)) : utype(denominator);
570 const utype abs_remainder = (remainder < 0) ? (utype(0) - utype(remainder)) : utype(remainder);
571 const utype half_denominator = abs_denominator / 2U;
572
573 // Compare without `* 2` to avoid unsigned overflow.
574 if ((abs_denominator & 1U) == 0U)
575 {
576 // Even denominator: can be exactly half.
577 if (abs_remainder < half_denominator)
578 {
579 return quotient;
580 }
581 else if (abs_remainder > half_denominator)
582 {
583 return quotient + direction;
584 }
585 else
586 {
587 // Exactly halfway, round to even
588 return (quotient & 1) == 0 ? quotient : quotient + direction;
589 }
590 }
591 else
592 {
593 // Odd denominator: no exact half case.
594 return (abs_remainder <= half_denominator) ? quotient : (quotient + direction);
595 }
596 }
597
598 //***************************************************************************
606 //***************************************************************************
607 template <typename T1, typename T2>
608 ETL_CONSTEXPR14
609 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_signed<T1>::value && etl::is_signed<T2>::value,
610 typename etl::common_type<T1, T2>::type>::type
611 divide_round_half_even(T1 numerator, T2 denominator) ETL_NOEXCEPT
612 {
613 typedef typename etl::common_type<T1, T2>::type type;
614
615 return divide_round_half_even(static_cast<type>(numerator), static_cast<type>(denominator));
616 }
617
618 //***************************************************************************
625 //***************************************************************************
626 template <typename T>
627 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_unsigned<T>::value, T>::type divide_round_half_even(T numerator,
628 T denominator)
629 ETL_NOEXCEPT
630 {
631 const T quotient = numerator / denominator;
632 const T remainder = numerator % denominator;
633
634 if ((remainder * 2U) < denominator)
635 {
636 // Less than halfway, round down
637 return quotient;
638 }
639 else if ((remainder * 2U) > denominator)
640 {
641 // More than halfway, round up
642 return quotient + 1U;
643 }
644 else
645 {
646 // Exactly halfway, round to even
647 return (quotient & 1U) == 0U ? quotient : quotient + 1;
648 }
649 }
650
651 //***************************************************************************
659 //***************************************************************************
660 template <typename T1, typename T2>
661 ETL_CONSTEXPR14
662 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_unsigned<T1>::value && etl::is_unsigned<T2>::value,
663 typename etl::common_type<T1, T2>::type>::type
664 divide_round_half_even(T1 numerator, T2 denominator) ETL_NOEXCEPT
665 {
666 typedef typename etl::common_type<T1, T2>::type type;
667
668 return divide_round_half_even(static_cast<type>(numerator), static_cast<type>(denominator));
669 }
670
671 //***************************************************************************
678 //***************************************************************************
679 template <typename T>
680 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_signed<T>::value, T>::type divide_round_half_odd(T numerator,
681 T denominator)
682 ETL_NOEXCEPT
683 {
684 const T quotient = numerator / denominator;
685 const T remainder = numerator % denominator;
686
687 typedef typename etl::make_unsigned<T>::type utype;
688 const utype abs_denominator = etl::absolute_unsigned(denominator);
689 const utype abs_remainder = etl::absolute_unsigned(remainder);
690 const utype half = abs_denominator / 2U;
691 const T direction = private_rounded_integral_division::are_same_sign(numerator, denominator) ? 1 : -1;
692
693 // Odd divisor => no exact-half case; 'half' is floor(abs_denominator/2).
694 if ((abs_denominator & 1U) != 0U)
695 {
696 return (abs_remainder > half) ? quotient + direction : quotient;
697 }
698
699 if (abs_remainder < half)
700 {
701 return quotient;
702 }
703 else if (abs_remainder > half)
704 {
705 return quotient + direction;
706 }
707 else
708 {
709 // Exactly halfway, round to odd
710 return (quotient & 1) != 0 ? quotient : quotient + direction;
711 }
712 }
713
714 //***************************************************************************
722 //***************************************************************************
723 template <typename T1, typename T2>
724 ETL_CONSTEXPR14
725 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_signed<T1>::value && etl::is_signed<T2>::value,
726 typename etl::common_type<T1, T2>::type>::type
727 divide_round_half_odd(T1 numerator, T2 denominator) ETL_NOEXCEPT
728 {
729 typedef typename etl::common_type<T1, T2>::type type;
730
731 return divide_round_half_odd(static_cast<type>(numerator), static_cast<type>(denominator));
732 }
733
734 //***************************************************************************
741 //***************************************************************************
742 template <typename T>
743 ETL_CONSTEXPR14 typename etl::enable_if< etl::is_integral<T>::value && etl::is_unsigned<T>::value, T>::type divide_round_half_odd(T numerator,
744 T denominator)
745 ETL_NOEXCEPT
746 {
747 const T quotient = numerator / denominator;
748 const T remainder = numerator % denominator;
749
750 if ((remainder * 2U) < denominator)
751 {
752 return quotient;
753 }
754 else if ((remainder * 2U) > denominator)
755 {
756 return quotient + 1U;
757 }
758 else
759 {
760 // Exactly halfway, round to odd
761 return (quotient & 1U) != 0U ? quotient : quotient + 1U;
762 }
763 }
764
765 //***************************************************************************
773 //***************************************************************************
774 template <typename T1, typename T2>
775 ETL_CONSTEXPR14
776 typename etl::enable_if< etl::is_integral<T1>::value && etl::is_integral<T2>::value && etl::is_unsigned<T1>::value && etl::is_unsigned<T2>::value,
777 typename etl::common_type<T1, T2>::type>::type
778 divide_round_half_odd(T1 numerator, T2 denominator) ETL_NOEXCEPT
779 {
780 typedef typename etl::common_type<T1, T2>::type type;
781
782 return divide_round_half_odd(static_cast<type>(numerator), static_cast<type>(denominator));
783 }
784} // namespace etl
785
786#endif
bitset_ext
Definition absolute.h:40
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_signed< T >::value, T >::type divide_round_half_odd(T numerator, T denominator) ETL_NOEXCEPT
Integral division with rounding to half odd. For signed integral types. For identical argument types.
Definition rounded_integral_division.h:680
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_signed< T >::value, T >::type divide_round_to_infinity(T numerator, T denominator) ETL_NOEXCEPT
Integral division with rounding towards infinity. For signed integral types. For identical argument t...
Definition rounded_integral_division.h:245
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_unsigned< T >::value, T >::type divide_round_to_zero(T numerator, T denominator) ETL_NOEXCEPT
Integral division with rounding towards zero. For integral types. For identical argument types.
Definition rounded_integral_division.h:331
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_signed< T >::value, T >::type divide_round_half_down(T numerator, T denominator) ETL_NOEXCEPT
Integral division with rounding to half down. For signed integral types. For identical argument types...
Definition rounded_integral_division.h:470
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_signed< T >::value, T >::type divide_round_half_up(T numerator, T denominator) ETL_NOEXCEPT
Integral division with rounding to half up. For signed integral types. For identical argument types.
Definition rounded_integral_division.h:369
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_signed< T >::value, T >::type divide_round_half_even(T numerator, T denominator) ETL_NOEXCEPT
Integral division with rounding to half even. For signed integral types. For identical argument types...
Definition rounded_integral_division.h:558
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_signed< T >::value, T >::type divide_round_to_floor(T numerator, T denominator) ETL_NOEXCEPT
Integral division with rounding to floor. For signed integral types. For identical argument types.
Definition rounded_integral_division.h:160
ETL_CONSTEXPR14 etl::enable_if< etl::is_integral< T >::value &&etl::is_signed< T >::value, T >::type divide_round_to_ceiling(T numerator, T denominator) ETL_NOEXCEPT
Integral division with rounding to ceiling. For signed integral types. For identical argument types.
Definition rounded_integral_division.h:74