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