12typedef void GENERATE_RANDOM_BYTES(
void * p, memsize s);
13using PFN_GENERATE_RANDOM_BYTES = GENERATE_RANDOM_BYTES *;
20inline ::std::strong_ordering strong_order(::f64 d1, ::f64 d2)
25 if(d > std::numeric_limits<::f64>::epsilon())
28 return ::std::strong_ordering::greater;
31 else if(d < -std::numeric_limits<::f64>::epsilon())
34 return ::std::strong_ordering::less;
40 return ::std::strong_ordering::equal;
46template < prototype_
signed SIGNED1, prototype_
signed SIGNED2 >
47inline constexpr bool __lt(
const SIGNED1 & a,
const SIGNED2 & b) {
return a < b; }
48template < prototype_
signed SIGNED1, prototype_
signed SIGNED2 >
49inline constexpr bool __le(
const SIGNED1 & a,
const SIGNED2 & b) {
return a <= b; }
50template < prototype_
unsigned UNSIGNED1, prototype_
signed SIGNED2 >
51inline constexpr bool __lt(
const UNSIGNED1 & a,
const SIGNED2 & b) {
return b < 0 ? false : a < static_cast < ::u32 > (b); }
52template < prototype_
unsigned UNSIGNED1, prototype_
signed SIGNED2 >
53inline constexpr bool __le(
const UNSIGNED1 & a,
const SIGNED2 & b) {
return b < 0 ? false : a <= static_cast <::u32> (b); }
56template < prototype_
signed SIGNED1, prototype_
unsigned UNSIGNED2 >
57inline constexpr bool __lt(
const SIGNED1 & a,
const UNSIGNED2 & b) {
return a < 0 ? true : static_cast <::u32> (a) < b; }
58template < prototype_
signed SIGNED1, prototype_
unsigned UNSIGNED2 >
59inline constexpr bool __le(
const SIGNED1 & a,
const UNSIGNED2 & b) {
return a < 0 ? false : static_cast <::u64> (a) <= b; }
62template < prototype_
unsigned UNSIGNED1, prototype_
unsigned UNSIGNED2 >
63inline constexpr bool __lt(
const UNSIGNED1 & a,
const UNSIGNED2 & b) {
return a < b; }
64template < prototype_
unsigned UNSIGNED1, prototype_
unsigned UNSIGNED2 >
65inline constexpr bool __le(
const UNSIGNED1 & a,
const UNSIGNED2 & b) {
return a <= b; }
68template < prototype_
integral INTEGRAL1, prototype_
floating FLOATING2 >
69inline constexpr bool __lt(
const INTEGRAL1 & a,
const FLOATING2 & b) {
return a < b; }
70template < prototype_
integral INTEGRAL1, prototype_
floating FLOATING2 >
71inline constexpr bool __le(
const INTEGRAL1 & a,
const FLOATING2 & b) {
return a <= b; }
74template < prototype_
floating FLOATING1, prototype_
integral INTEGRAL2 >
75inline constexpr bool __lt(
const FLOATING1 & a,
const INTEGRAL2 & b) {
return a < b; }
76template < prototype_
floating FLOATING1, prototype_
integral INTEGRAL2 >
77inline constexpr bool __le(
const FLOATING1 & a,
const INTEGRAL2 & b) {
return a <= b; }
80template < prototype_
floating FLOATING1, prototype_
floating FLOATING2 >
81inline constexpr bool __lt(
const FLOATING1 & a,
const FLOATING2 & b) {
return a < b; }
82template < prototype_
floating FLOATING1, prototype_
floating FLOATING2 >
83inline constexpr bool __le(
const FLOATING1 & a,
const FLOATING2 & b) {
return a <= b; }
160 template <
typename T1,
typename T2 >
166 constexpr ::std::strong_ordering order(
const T1 & t1,
const T2 & t2)
const
177 template < prototype_
signed S1, prototype_
signed S2 >
178 constexpr ::std::strong_ordering order(S1 s1, S2 s2)
186 template < prototype_
signed S1, prototype_
signed S2 >
191 constexpr ::std::strong_ordering order(S1 s1, S2 s2)
const
200template < prototype_
unsigned U1, prototype_
unsigned U2 >
201constexpr ::std::strong_ordering order(U1 u1, U2 u2)
207 template < prototype_
unsigned U1, prototype_
unsigned U2 >
212 constexpr ::std::strong_ordering order(U1 u1, U2 u2)
const
221template < prototype_
signed S, prototype_
unsigned U >
222constexpr ::std::strong_ordering order(S s, U u)
225 return s < 0 ? ::std::strong_ordering::less : ::std::make_unsigned_t<S>(s) <=> u;
228 template < prototype_
signed S, prototype_
unsigned U >
233 constexpr ::std::strong_ordering order(S s, U u)
const
236 return s < 0 ? ::std::strong_ordering::less : ::std::make_unsigned_t<S>(s) <=> u;
241template < prototype_
unsigned U, prototype_
signed S >
242constexpr ::std::strong_ordering order(U u, S s)
245 return s < 0 ? ::std::strong_ordering::greater : u <=> ::std::make_unsigned_t<S>(s);
248 template < prototype_
unsigned U, prototype_
signed S >
255 constexpr ::std::strong_ordering order(U u, S s)
const
258 return s < 0 ? ::std::strong_ordering::greater : u <=> ::std::make_unsigned_t<S>(s);
263template < prototype_
floating F1, prototype_
floating F2 >
265constexpr ::std::strong_ordering order(F1 f1, F2 f2)
268 return ::strong_order(f1, f2);
271 template < prototype_
floating F1, prototype_
floating F2 >
276 constexpr ::std::strong_ordering order(F1 f1, F2 f2)
const
279 return ::strong_order(f1, f2);
285template < prototype_
floating F, prototype_
integral T >
287constexpr ::std::strong_ordering order(F f, T t)
295 return ::std::strong_ordering::greater;
301 return ::std::strong_ordering::less;
307 return ::std::strong_ordering::equal;
313 return ::std::strong_order(f, (F)t);
320 template < prototype_
floating F, prototype_
integral T >
325 constexpr ::std::strong_ordering order(F f, T t)
const
333 return ::std::strong_ordering::greater;
339 return ::std::strong_ordering::less;
345 return ::std::strong_ordering::equal;
351 return ::std::strong_order(f, (F)t);
361template < prototype_
integral T, prototype_
floating F >
362constexpr ::std::strong_ordering order(T t, F f)
370 return ::std::strong_ordering::greater;
376 return ::std::strong_ordering::less;
382 return ::std::strong_ordering::equal;
388 return ::std::strong_order((F) t, f);
394 template < prototype_
integral T, prototype_
floating F >
399 constexpr ::std::strong_ordering order(T t, F f)
const
407 return ::std::strong_ordering::greater;
413 return ::std::strong_ordering::less;
419 return ::std::strong_ordering::equal;
425 return ::std::strong_order((F) t, f);
447template <
typename TYPE >
448constexpr TYPE maximum(
const TYPE & a,
const TYPE & b)
451 return a < b ? b : a;
456template<
typename TYPE,
typename COMPARE >
457constexpr TYPE compare_reduce(std::initializer_list<TYPE>
list_base, COMPARE compare)
492template<
typename TYPE >
493constexpr TYPE maximum(std::initializer_list<TYPE>
list_base)
496 return compare_reduce(
list_base, [](
auto a,
auto b) {
return a > b; });
501template<
typename TYPE >
502constexpr TYPE minimum(std::initializer_list<TYPE>
list_base)
505 return compare_reduce(
list_base, [](
auto a,
auto b) {
return a < b; });
510template <
typename TYPE1,
typename TYPE2 >
511constexpr largest_type<TYPE1, TYPE2> maximum(
const TYPE1 & a,
const TYPE2 & b)
514 return ::comparison::comparison2<TYPE1, TYPE2>().order(a, b) >= 0 ?
515 (largest_type<TYPE1, TYPE2>) a : (largest_type<TYPE1, TYPE2>)b;
520template < prototype_number TYPE1, prototype_number TYPE2 >
521constexpr smallest_type<TYPE1, TYPE2> natural_minimum(
const TYPE1 & a,
const TYPE2 & b)
524 return ::comparison::comparison2<TYPE1, TYPE2>().order(a, b) <= 0 ?
525 (smallest_type<TYPE1, TYPE2>) maximum(0, a) : (smallest_type<TYPE1, TYPE2>)maximum(0, b);
530template < prototype_
unsigned TYPE1, prototype_
unsigned TYPE2 >
531constexpr smallest_type<TYPE1, TYPE2> minimum(
const TYPE1 & a,
const TYPE2 & b)
534 return ::comparison::comparison2<TYPE1, TYPE2>().order(a, b) <= 0 ?
535 (smallest_type<TYPE1, TYPE2>) a : (smallest_type<TYPE1, TYPE2>)b;
540template <
typename TYPE1,
typename TYPE2 >
541constexpr largest_type<TYPE1, TYPE2> minimum(
const TYPE1 & a,
const TYPE2 & b)
544 return ::comparison::comparison2<TYPE1, TYPE2>().order(a, b) <= 0 ?
545 (largest_type<TYPE1, TYPE2>) a : (largest_type<TYPE1, TYPE2>)b;
550CLASS_DECL_ACME ::i64 ceil_div(::i64 num, ::i64 den);
553CLASS_DECL_ACME ::f64 tri(::f64 angle);
566CLASS_DECL_ACME ::i32 ccvt_dup(char_pointer buf,::i32 nchar, ::f64 arg, ::i32 ndigits,::i32 *decpt,::i32 *sign,::i32 eflag);
567CLASS_DECL_ACME ::i32 ecvt_dup(char_pointer buf,::i32 nchar, ::f64 arg, ::i32 ndigits,::i32 *decpt,::i32 *sign);
568CLASS_DECL_ACME ::i32 fcvt_dup(char_pointer buf,::i32 nchar, ::f64 arg, ::i32 ndigits,::i32 *decpt,::i32 *sign);
569CLASS_DECL_ACME ::i32 gcvt_dup(char_pointer buf,::i32 nchar, ::f64 arg, ::i32 ndigits);
570CLASS_DECL_ACME ::i32 max_cvt_dup(char_pointer buf,::i32 nchar,::f64 arg,::i32 ndigits,::i32 *decpt,::i32 *sign, ::i32 * pi);
575#define MATH_PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844
576#define MATH_HALF_PI 1.570796326794896619231321691639751442098584699687552910487472296153908203143104499314017412671058533991074043256641153323546922
577#define DEGREE_RADIAN 0.01745329251994329576923690768488612713442871888541725456097191440171009114603449443682241569634509482212304492507379059248385468
578#define RADIAN_DEGREE 57.29577951308232087679815481410517033240547246656432154916024386120284714832155263244096899585111094418622338163286489328144827
586 inline CLASS_DECL_ACME ::f64 to_radian(::f64 dAngleDegrees)
589 return dAngleDegrees * DEGREE_RADIAN;
593 inline CLASS_DECL_ACME ::f64 sin(::f64 dAngleDegrees)
596 return ::sin(to_radian(dAngleDegrees));
600 inline CLASS_DECL_ACME ::f64 cos(::f64 dAngleDegrees)
603 return ::cos(to_radian(dAngleDegrees));
607 inline CLASS_DECL_ACME ::f64 tan(::f64 dAngleDegrees)
610 return ::tan(to_radian(dAngleDegrees));
620inline ::u8 __byte_rate(::f64 dRate, ::f64 dMin, ::f64 dMax)
623 return (::u8)(dRate * (dMax - dMin) + dMin);
628template <
typename TYPE >
629inline TYPE range_rate(TYPE iMin, TYPE iMax, ::f64 dRate)
631 return (TYPE)((iMax - iMin) * dRate) + iMin;
636#include "number_limits.h"
640template < prototype_
integral_number INTEGRAL_NUMBER >
641constexpr ::i16 __loword(INTEGRAL_NUMBER i)
647template<prototype_
integral_number INTEGRAL_NUMBER>
648constexpr ::i16 __hiword(INTEGRAL_NUMBER i)
650 return (i >> 16) & 0xffff;
664CLASS_DECL_ACME ::i32 type_maximum_digits(enum_integer_type etype, ::i32 iBase = 10);
667template < prototype_
signed SIGNED >
668inline ::i32 maximum_digits(::i32 iBase)
671 if constexpr (
sizeof(SIGNED) == 1)
674 return type_maximum_digits(e_integer_type_char, iBase);
677 else if constexpr (
sizeof(SIGNED) == 2)
680 return type_maximum_digits(e_integer_type_short, iBase);
683 else if constexpr (
sizeof(SIGNED) == 4)
686 return type_maximum_digits(e_integer_type_int, iBase);
689 else if constexpr (
sizeof(SIGNED) == 8)
692 return type_maximum_digits(e_integer_type_i64, iBase);
698 throw_exception(error_unexpected);
707template < prototype_
unsigned UNSIGNED >
708inline ::i32 maximum_digits(::i32 iBase)
711 if constexpr (
sizeof(UNSIGNED) == 1)
714 return type_maximum_digits(e_integer_type_unsigned_char, iBase);
717 else if constexpr (
sizeof(UNSIGNED) == 2)
720 return type_maximum_digits(e_integer_type_unsigned_short, iBase);
723 else if constexpr (
sizeof(UNSIGNED) == 4)
726 return type_maximum_digits(e_integer_type_u32, iBase);
729 else if constexpr (
sizeof(UNSIGNED) == 8)
732 return type_maximum_digits(e_integer_type_u64, iBase);
738 throw_exception(error_unexpected);
761inline T square_power(T v)
Definition mathematics.h:29