Vuo  2.1.2
VuoInteger.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #include <stdint.h>
17 #include <stdbool.h>
18 #include <math.h>
19 struct json_object;
20 
32 typedef int64_t VuoInteger;
33 
35 typedef const struct VuoList_VuoInteger_struct { void *l; } * VuoList_VuoInteger;
37 #define VuoList_VuoInteger_TYPE_DEFINED
38 
40 struct json_object * VuoInteger_getJson(const VuoInteger value);
41 char * VuoInteger_getSummary(const VuoInteger value);
42 
46 
48 
49 VuoInteger VuoInteger_random(const VuoInteger minimum, const VuoInteger maximum);
50 
51 void VuoInteger_setRandomState(unsigned short state[3], const VuoInteger seed);
52 VuoInteger VuoInteger_randomWithState(unsigned short state[3], const VuoInteger minimum, const VuoInteger maximum);
53 
54 VuoInteger VuoInteger_makeFromHexByte(unsigned char byte);
55 
61 static inline VuoInteger VuoInteger_add(VuoInteger a, VuoInteger b) __attribute__((const));
63 {
64  return a+b;
65 }
66 
72 static inline VuoInteger VuoInteger_subtract(VuoInteger a, VuoInteger b) __attribute__((const));
74 {
75  return a-b;
76 }
77 
81 static inline VuoInteger VuoInteger_multiply(VuoInteger a, VuoInteger b) __attribute__((const));
83 {
84  return a*b;
85 }
86 
90 static inline VuoInteger VuoInteger_scale(VuoInteger a, VuoInteger b) __attribute__((const));
92 {
93  return a*b;
94 }
95 
101 static inline VuoInteger VuoInteger_divide(VuoInteger a, VuoInteger b) __attribute__((const));
103 {
104  return a/b;
105 }
106 
110 static inline VuoInteger VuoInteger_makeNonzero(VuoInteger a) __attribute__((const));
112 {
113  return a ? a : 1;
114 }
115 
119 static inline VuoInteger VuoInteger_snap(VuoInteger a, VuoInteger center, VuoInteger snap) __attribute__((const));
121 {
122  if (snap == 0)
123  return a;
124  return center + snap * ((a-center) / snap);
125 }
126 
128 #define VuoInteger_SUPPORTS_COMPARISON
129 bool VuoInteger_areEqual(const VuoInteger value1, const VuoInteger value2);
131 bool VuoInteger_isLessThan(const VuoInteger a, const VuoInteger b);
132 bool VuoInteger_isWithinRange(VuoInteger value, VuoInteger minimum, VuoInteger maximum);
133 
134 #ifndef MIN
135 
138 #define MIN(a,b) (((a)<(b))?(a):(b))
139 #endif
140 
141 #ifndef MAX
142 
145 #define MAX(a,b) (((a)>(b))?(a):(b))
146 #endif
147 
151 static inline VuoInteger VuoInteger_clamp(VuoInteger value, VuoInteger limitA, VuoInteger limitB)
152 {
153  return MIN(MAX(value, MIN(limitA, limitB)), MAX(limitA,limitB));
154 }
155 
160 static inline VuoInteger VuoInteger_clampn(VuoInteger value, VuoInteger limitA, VuoInteger limitB)
161 {
162  return VuoInteger_clamp(value, limitA, limitB);
163 }
164 
166 
170 char * VuoInteger_getString(const VuoInteger value);
174 
179 #ifdef __cplusplus
180 }
181 #endif