Vuo 2.4.4
Loading...
Searching...
No Matches
VuoInteger.h
Go to the documentation of this file.
1
10#ifndef VuoInteger_h
11#define VuoInteger_h
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#include <stdint.h>
18#include <math.h>
19
31typedef int64_t VuoInteger;
32
33#define VuoInteger_SUPPORTS_COMPARISON
34#include "VuoList_VuoInteger.h"
35
36VuoInteger VuoInteger_makeFromJson(struct json_object * js);
37struct json_object * VuoInteger_getJson(const VuoInteger value);
38char * VuoInteger_getSummary(const VuoInteger value);
39
43
45
46VuoInteger VuoInteger_random(const VuoInteger minimum, const VuoInteger maximum);
47
48void VuoInteger_setRandomState(unsigned short state[3], const VuoInteger seed);
49VuoInteger VuoInteger_randomWithState(unsigned short state[3], const VuoInteger minimum, const VuoInteger maximum);
50
51VuoInteger VuoInteger_makeFromHexByte(unsigned char byte);
52
58static inline VuoInteger VuoInteger_add(VuoInteger a, VuoInteger b) __attribute__((const));
60{
61 return a+b;
62}
63
69static inline VuoInteger VuoInteger_subtract(VuoInteger a, VuoInteger b) __attribute__((const));
71{
72 return a-b;
73}
74
78static inline VuoInteger VuoInteger_multiply(VuoInteger a, VuoInteger b) __attribute__((const));
80{
81 return a*b;
82}
83
87static inline VuoInteger VuoInteger_scale(VuoInteger a, VuoInteger b) __attribute__((const));
89{
90 return a*b;
91}
92
98static inline VuoInteger VuoInteger_divide(VuoInteger a, VuoInteger b) __attribute__((const));
100{
101 return a/b;
102}
103
107static inline VuoInteger VuoInteger_makeNonzero(VuoInteger a) __attribute__((const));
109{
110 return a ? a : 1;
111}
112
116static inline VuoInteger VuoInteger_snap(VuoInteger a, VuoInteger center, VuoInteger snap) __attribute__((const));
118{
119 if (snap == 0)
120 return a;
121 return center + snap * ((a-center) / snap);
122}
123
124bool VuoInteger_areEqual(const VuoInteger value1, const VuoInteger value2);
126bool VuoInteger_isLessThan(const VuoInteger a, const VuoInteger b);
127bool VuoInteger_isWithinRange(VuoInteger value, VuoInteger minimum, VuoInteger maximum);
128
129#ifndef MIN
133#define MIN(a,b) (((a)<(b))?(a):(b))
134#endif
135
136#ifndef MAX
140#define MAX(a,b) (((a)>(b))?(a):(b))
141#endif
142
146static inline VuoInteger VuoInteger_clamp(VuoInteger value, VuoInteger limitA, VuoInteger limitB)
147{
148 return MIN(MAX(value, MIN(limitA, limitB)), MAX(limitA,limitB));
149}
150
155static inline VuoInteger VuoInteger_clampn(VuoInteger value, VuoInteger limitA, VuoInteger limitB)
156{
157 return VuoInteger_clamp(value, limitA, limitB);
158}
159
161
168
173#ifdef __cplusplus
174}
175#endif
176
177#endif