Skip to main content

Size of Byte Array for Storing Ux Binary Data

Name

UxHwDoubleGetSizeOfDistributionByteArrayInBytes, UxHwFloatGetSizeOfDistributionByteArrayInBytes Get the required size in bytes for storing the Ux Binary data of a distribution.

Synopsis

#include <stddef.h>
#include <uxhw.h>

size_t UxHwDoubleGetSizeOfDistributionByteArrayInBytes(double value);
size_t UxHwFloatGetSizeOfDistributionByteArrayInBytes(float value);

Description

On architectures that associate distributional information with floating-point values, the UxHwDoubleGetSizeOfDistributionByteArrayInBytes() function returns the required size in bytes of an unsigned byte array that can safely hold the Ux Binary data associated with source variable value. Because different Signaloid C0 uncertainty-tracking core variants use different amounts of memory for storing distributional information we strongly suggest that you do not use a fixed-size byte array for storing Ux Binary data, but rather use the UxHwDoubleGetSizeOfDistributionByteArrayInBytes() function to dynamically allocate the space required for storing the Ux Binary data of a floating-point variable.

Parameters

  • value The distributional value whose Ux Binary data size will be calculated.

Return Values

The UxHwDoubleGetSizeOfDistributionByteArrayInBytes() function returns the amount of bytes required for storing the Ux Binary data of value.

  Examples

#include <stdio.h>
#include <stddef.h>
#include <uxhw.h>

int
main(void)
{
/*
* Example where we initialize `value` as a Uniform distribution.
* The same steps apply for any distribution associated with `value`,
* whether parametric or empirical.
*/
double value = UxHwDoubleUniformDist(0.1, 1.0);
size_t destByteBufferSizeInBytes;

destByteBufferSizeInBytes = UxHwDoubleGetSizeOfDistributionByteArrayInBytes(value);

printf("The Ux Binary data of `value` are %zu bytes long.\n", destByteBufferSizeInBytes);

return 0;
}