Vuo  1.2.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
VuoInteger.c File Reference

Description

VuoInteger implementation.

Functions

VuoInteger VuoInteger_makeFromJson (json_object *js)
 Decodes the JSON object js, expected to contain a 64-bit integer, to create a new value.
 
json_objectVuoInteger_getJson (const VuoInteger value)
 Encodes value as a JSON object.
 
char * VuoInteger_getSummary (const VuoInteger value)
 Always shows the full value, since it's guaranteed to be pretty short.
 
VuoInteger VuoInteger_min (VuoInteger *terms, unsigned long termsCount)
 Returns the minimum of an array of terms, or 0 if the array is empty.
 
VuoInteger VuoInteger_max (VuoInteger *terms, unsigned long termsCount)
 Returns the maximum of an array of terms, or 0 if the array is empty.
 
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.
 
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".
 
VuoInteger VuoInteger_random (const VuoInteger minimum, const VuoInteger maximum)
 Returns a pseudorandom value between minimum and maximum, inclusive.
 
void VuoInteger_setRandomState (unsigned short state[3], const VuoInteger seed)
 Initializes state using the lower 48 bits of seed.
 
VuoInteger VuoInteger_randomWithState (unsigned short state[3], const VuoInteger minimum, const VuoInteger maximum)
 Returns a pseudorandom value between minimum and maximum, inclusive.
 
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.
 

Variables

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

Function Documentation

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.

Variable Documentation

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.