Euphoria
cint.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "base/ints.h"
4 
5 #include <cstddef>
6 
7 
8 namespace eu
9 {
10  int
11  c_sizet_to_int(size_t t);
12 
13 
14  int
15  c_unsigned_int_to_int(unsigned int i);
16 
17 
18  unsigned int
19  c_int_to_unsigned_int(int i);
20 
21 
22  size_t
23  c_int_to_sizet(int i);
24 
25 
26  U8
27  c_int_to_u8(unsigned int i);
28 
29 
30  int
31  c_u64_to_int(U64 u);
32 
33 
34  // todo(Gustav): deprecate and replace with floor_to_int or ceil_to_int
35  constexpr int
36  c_float_to_int(float f)
37  {
38  return static_cast<int>(f);
39  }
40 
41 
42  constexpr float
43  c_sizet_to_float(std::size_t f)
44  {
45  return static_cast<float>(f);
46  }
47 
48 
49  constexpr float
51  {
52  return static_cast<float>(i);
53  }
54 
55 
56  constexpr float
58  {
59  return static_cast<float>(i);
60  }
61 
62 
63  constexpr U32
65  {
66  union { I32 s; U32 u; } c = {};
67  c.s = i;
68  return c.u;
69  }
70 
71 
72  constexpr double
74  {
75  return static_cast<double>(f);
76  }
77 
78 
79  constexpr float
81  {
82  return static_cast<float>(f);
83  }
84 }
Definition: assert.h:90
constexpr float c_sizet_to_float(std::size_t f)
Definition: cint.h:43
constexpr float c_double_to_float(double f)
Definition: cint.h:80
int c_sizet_to_int(size_t t)
Definition: cint.cc:11
int c_u64_to_int(U64 u)
Definition: cint.cc:49
constexpr float c_u64_to_float(U64 i)
Definition: cint.h:57
size_t c_int_to_sizet(int i)
Definition: cint.cc:35
constexpr int c_float_to_int(float f)
Definition: cint.h:36
constexpr U32 c_bit_signed_to_unsigned(I32 i)
Definition: cint.h:64
std::int32_t I32
Definition: ints.h:8
std::uint32_t U32
Definition: ints.h:13
U8 c_int_to_u8(unsigned int i)
Definition: cint.cc:42
std::uint8_t U8
Definition: ints.h:15
constexpr float c_int_to_float(int i)
Definition: cint.h:50
constexpr double c_float_to_double(float f)
Definition: cint.h:73
int c_unsigned_int_to_int(unsigned int i)
Definition: cint.cc:19
std::uint64_t U64
Definition: ints.h:12
unsigned int c_int_to_unsigned_int(int i)
Definition: cint.cc:27