Vuo  2.1.0
Functions | Variables
VuoInteger.c File Reference

Description

VuoInteger implementation.

Definition in file VuoInteger.c.

Go to the source code of this file.

Functions

VuoInteger VuoInteger_makeFromJson (json_object *js)
 
json_objectVuoInteger_getJson (const VuoInteger value)
 
char * VuoInteger_getSummary (const VuoInteger value)
 
VuoInteger VuoInteger_minList (VuoList_VuoInteger values, VuoInteger *outputPosition)
 Returns the minimum of a list of terms, or 0 if the array is empty. More...
 
VuoInteger VuoInteger_maxList (VuoList_VuoInteger values, VuoInteger *outputPosition)
 Returns the maximum of a list of terms, or 0 if the array is empty. More...
 
VuoInteger VuoInteger_average (VuoList_VuoInteger values)
 Returns the average of the values in the list, or 0 if the list is empty. More...
 
VuoInteger VuoInteger_wrap (VuoInteger value, VuoInteger minimum, VuoInteger maximum)
 Returns value if it is within the range of minimum to maximum (inclusive), otherwise a value wrapped with modular arithmetic to be within the range. More...
 
static u_int32_t VuoInteger_arc4random_uniform (u_int32_t upper_bound)
 Calculate a uniformly distributed random number less than upper_bound avoiding "modulo bias". More...
 
VuoInteger VuoInteger_random (const VuoInteger minimum, const VuoInteger maximum)
 Returns a pseudorandom value between minimum and maximum, inclusive. More...
 
void VuoInteger_setRandomState (unsigned short state[3], const VuoInteger seed)
 Initializes state using the lower 48 bits of seed. More...
 
VuoInteger VuoInteger_randomWithState (unsigned short state[3], const VuoInteger minimum, const VuoInteger maximum)
 Returns a pseudorandom value between minimum and maximum, inclusive. More...
 
VuoInteger VuoInteger_makeFromHexByte (unsigned char byte)
 If byte is a valid ASCII hex character (0–9, a–f, A–F), returns the equivalent numeric value. More...
 
bool VuoInteger_areEqual (const VuoInteger value1, const VuoInteger value2)
 Returns true if the two values are equal. More...
 
bool VuoInteger_areEqualListWithinTolerance (VuoList_VuoInteger values, VuoInteger tolerance)
 Returns true if the two values are equal within tolerance. More...
 
bool VuoInteger_isLessThan (const VuoInteger a, const VuoInteger b)
 Returns true if a < b. More...
 
bool VuoInteger_isWithinRange (VuoInteger value, VuoInteger minimum, VuoInteger maximum)
 Returns true if value is between minimum and maximum. More...
 

Variables

static const char VuoInteger_hexToDec [256]
 Convert between hex and decimal. More...
 

Function Documentation

◆ VuoInteger_arc4random_uniform()

static u_int32_t VuoInteger_arc4random_uniform ( u_int32_t  upper_bound)
static

Calculate a uniformly distributed random number less than upper_bound avoiding "modulo bias".

Uniformity is achieved by generating new random numbers until the one returned is outside the range [0, 2**32 % upper_bound). This guarantees the selected random number will be inside [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound) after reduction modulo upper_bound.

Copyright (c) 1999,2000,2004 Damien Miller djm@m.nosp@m.indr.nosp@m.ot.or.nosp@m.g

Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Definition at line 180 of file VuoInteger.c.

Variable Documentation

◆ VuoInteger_hexToDec

const char VuoInteger_hexToDec[256]
static
Initial value:
=
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Convert between hex and decimal.

Definition at line 276 of file VuoInteger.c.