Float
Description
Decimal arbitrary-precision floating-point value. The number represented is (-1)^negative * significand * 10^exponent.
Fields
| Name | Description |
|---|---|
negative |
Sign flag. Zero is always normalized to non-negative. |
significand |
Integer significand stored without decimal point. |
exponent |
Base-10 exponent applied to the significand. |
Usage example (from documentation)
Float value = FloatFromStr("12.5");Usage example (Cross-references)
Usage examples (Cross-references)
- In
Container.h:34:
#endif
#if FEATURE_FLOAT
# include <Misra/Std/Container/Float.h>
#endif- In
Io.h:235:
#if FEATURE_FLOAT
# define IOFMT_FLOAT_CASE_(x, addr) \
Float: \
TO_TYPE_SPECIFIC_IO(Float, addr),
#else- In
Io.h:236:
# define IOFMT_FLOAT_CASE_(x, addr) \
Float: \
TO_TYPE_SPECIFIC_IO(Float, addr),
#else
# define IOFMT_FLOAT_CASE_(x, addr)- In
Io.h:395:
/// TAGS: Float, Format, Decimal
///
bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc);
# define FloatTryToDecimalStr(...) OVERLOAD(FloatTryToDecimalStr, __VA_ARGS__)
# define FloatTryToDecimalStr_4(out, value, precision, has_precision) \- In
Io.h:422:
bool float_try_to_scientific_str(
Str *out,
Float *value,
u32 precision,
bool has_precision,- In
Io.h:752:
bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
#if FEATURE_FLOAT
bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
#endif
#if FEATURE_BITVEC- In
Io.h:777:
Zstr _read_f64(Zstr i, FmtInfo *fmt_info, f64 *v);
#if FEATURE_FLOAT
Zstr _read_Float(Zstr i, FmtInfo *fmt_info, Float *value);
#endif
#if FEATURE_BITVEC- In
Float.h:10:
#define MISRA_STD_CONTAINER_FLOAT_H
#include "Float/Type.h"
#include "Float/Init.h"
#include "Float/Access.h"- In
Float.h:11:
#include "Float/Type.h"
#include "Float/Init.h"
#include "Float/Access.h"
#include "Float/Memory.h"- In
Float.h:12:
#include "Float/Type.h"
#include "Float/Init.h"
#include "Float/Access.h"
#include "Float/Memory.h"
#include "Float/Convert.h"- In
Float.h:13:
#include "Float/Init.h"
#include "Float/Access.h"
#include "Float/Memory.h"
#include "Float/Convert.h"
#include "Float/Private.h"- In
Float.h:14:
#include "Float/Access.h"
#include "Float/Memory.h"
#include "Float/Convert.h"
#include "Float/Private.h"
#include "Float/Compare.h"- In
Float.h:15:
#include "Float/Memory.h"
#include "Float/Convert.h"
#include "Float/Private.h"
#include "Float/Compare.h"
#include "Float/Math.h"- In
Float.h:16:
#include "Float/Convert.h"
#include "Float/Private.h"
#include "Float/Compare.h"
#include "Float/Math.h"- In
Float.h:17:
#include "Float/Private.h"
#include "Float/Compare.h"
#include "Float/Math.h"
#endif // MISRA_STD_CONTAINER_FLOAT_H
- In
Memory.h:33:
/// TAGS: Float, Memory, Clone, Copy
///
bool FloatTryClone(Float *out, const Float *value);
///
- In
Memory.h:54:
/// TAGS: Float, Memory, Clone, Copy
///
Float FloatClone(const Float *value);
#ifdef __cplusplus- In
Compare.h:40:
/// TAGS: Float, Compare, Ordering, GenericCompare
///
int float_compare_with_error(const Float *lhs, const Float *rhs, bool *error);
i32 float_compare(const void *lhs, const void *rhs);- In
Compare.h:93:
_Generic( \
(rhs), \
Float *: float_compare, \
Int *: float_compare_int, \
unsigned char: float_compare_u64, \
- In
Compare.h:111:
_Generic( \
(rhs), \
Float *: float_compare_with_error, \
Int *: float_compare_int_with_error, \
unsigned char: float_compare_u64_with_error, \
- In
Type.h:30:
Int significand;
i64 exponent;
} Float;
///
- In
Type.h:43:
/// TAGS: Float, Validate, Safety, Debug
///
static inline void ValidateFloat(const Float *value) {
ValidateInt(value ? &value->significand : NULL);
}- In
Convert.h:64:
/// TAGS: Float, Convert, Int, Truncate
///
bool FloatToInt(Int *result, const Float *value);
///
- In
Convert.h:85:
/// TAGS: Float, Convert, Parse, Decimal
///
bool float_try_from_str_zstr(Float *out, Zstr text);
bool float_try_from_str_str(Float *out, const Str *text);
#define FloatTryFromStr(out, text) \- In
Convert.h:86:
///
bool float_try_from_str_zstr(Float *out, Zstr text);
bool float_try_from_str_str(Float *out, const Str *text);
#define FloatTryFromStr(out, text) \
_Generic((text), Str *: float_try_from_str_str, Zstr: float_try_from_str_zstr, char *: float_try_from_str_zstr)( \- In
Convert.h:104:
/// TAGS: Float, Convert, String
///
Float float_from_str_zstr(Zstr text, Allocator *alloc);
Float float_from_str_str(const Str *text, Allocator *alloc);
#define FloatFromStr(...) OVERLOAD(FloatFromStr, __VA_ARGS__)- In
Convert.h:105:
///
Float float_from_str_zstr(Zstr text, Allocator *alloc);
Float float_from_str_str(const Str *text, Allocator *alloc);
#define FloatFromStr(...) OVERLOAD(FloatFromStr, __VA_ARGS__)
#define FloatFromStr_1(text) \- In
Convert.h:118:
)
bool float_try_to_str(Str *out, const Float *value, Allocator *alloc);
Str float_to_str(const Float *value, Allocator *alloc);- In
Convert.h:119:
bool float_try_to_str(Str *out, const Float *value, Allocator *alloc);
Str float_to_str(const Float *value, Allocator *alloc);
#ifdef __cplusplus- In
Init.h:31:
///
#define FloatInit(...) OVERLOAD(FloatInit, __VA_ARGS__)
#define FloatInit_0() ((Float) {.negative = false, .significand = IntInit_1(MisraScope), .exponent = 0})
#define FloatInit_1(allocator_ptr) ((Float) {.negative = false, .significand = IntInit_1(allocator_ptr), .exponent = 0})- In
Init.h:32:
#define FloatInit(...) OVERLOAD(FloatInit, __VA_ARGS__)
#define FloatInit_0() ((Float) {.negative = false, .significand = IntInit_1(MisraScope), .exponent = 0})
#define FloatInit_1(allocator_ptr) ((Float) {.negative = false, .significand = IntInit_1(allocator_ptr), .exponent = 0})
///
- In
Init.h:44:
/// TAGS: Float, Deinit, Memory
///
static inline void FloatDeinit(Float *value) {
ValidateFloat(value);
IntDeinit(&value->significand);- In
Init.h:62:
/// TAGS: Float, Clear, Zero, Reset
///
static inline void FloatClear(Float *value) {
ValidateFloat(value);
IntClear(&value->significand);- In
Access.h:41:
/// TAGS: Float, Access, Zero, Predicate
///
bool FloatIsZero(const Float *value);
///
/// Test whether a floating-point value is negative.
- In
Access.h:56:
/// TAGS: Float, Access, Negative, Predicate
///
bool FloatIsNegative(const Float *value);
///
/// Read the base-10 exponent of a float.
- In
Access.h:71:
/// TAGS: Float, Access, Exponent
///
i64 FloatExponent(const Float *value);
#ifdef __cplusplus- In
Math.h:34:
/// TAGS: Float, Math, Negate, Sign
///
void FloatNegate(Float *value);
///
/// Replace a float with its absolute value.
- In
Math.h:49:
/// TAGS: Float, Math, AbsoluteValue
///
void FloatAbs(Float *value);
///
/// Add two floats.
- In
Math.h:66:
/// TAGS: Float, Math, Add
///
bool float_add(Float *result, const Float *a, const Float *b);
///
/// Subtract one float from another.
- In
Math.h:83:
/// TAGS: Float, Math, Subtract
///
bool float_sub(Float *result, const Float *a, const Float *b);
///
/// Multiply two floats.
- In
Math.h:100:
/// TAGS: Float, Math, Multiply
///
bool float_mul(Float *result, const Float *a, const Float *b);
///
/// Divide one float by another.
- In
Math.h:120:
/// TAGS: Float, Math, Divide, Precision
///
bool float_div(Float *result, const Float *a, const Float *b, u64 precision);
#ifndef __cplusplus
///
- In
Math.h:142:
_Generic( \
(b), \
Float *: float_add, \
Int *: float_add_int, \
unsigned char: float_add_u64, \
- In
Math.h:177:
_Generic( \
(b), \
Float *: float_sub, \
Int *: float_sub_int, \
unsigned char: float_sub_u64, \
- In
Math.h:213:
_Generic( \
(b), \
Float *: float_mul, \
Int *: float_mul_int, \
unsigned char: float_mul_u64, \
- In
Math.h:251:
_Generic( \
(b), \
Float *: float_div, \
Int *: float_div_int, \
unsigned char: float_div_u64, \
- In
Io.c:30:
#endif
#if FEATURE_FLOAT
# include <Misra/Std/Container/Float.h>
#endif- In
Io.c:1362:
}
bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc) {
Str canonical;
Str result;- In
Io.c:1451:
bool float_try_to_scientific_str(
Str *out,
Float *value,
u32 precision,
bool has_precision,- In
Io.c:2239:
#if FEATURE_FLOAT
bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value) {
size start_len = 0;
Str temp;- In
Io.c:2252:
if (float_fmt_uses_unsupported_flags(fmt_info)) {
LOG_FATAL("Float only supports decimal and scientific formatting");
}- In
Io.c:3396:
#if FEATURE_FLOAT
Zstr _read_Float(Zstr i, FmtInfo *fmt_info, Float *value) {
size token_len = 0;
Zstr start = NULL;- In
Io.c:3400:
Zstr start = NULL;
Str temp;
Float parsed;
if (!i || !value) {- In
Io.c:3410:
if (float_fmt_uses_unsupported_flags(fmt_info)) {
LOG_ERROR("Float only supports decimal and scientific reading");
StrDeinit(&temp);
FloatDeinit(&parsed);- In
Io.c:3426:
if (!StrIterRemainingLength(&si)) {
LOG_ERROR("Failed to parse Float: empty input");
StrDeinit(&temp);
FloatDeinit(&parsed);- In
Io.c:3436:
if (token_len == 0) {
LOG_ERROR("Failed to parse Float");
StrDeinit(&temp);
FloatDeinit(&parsed);- In
Float.c:7:
/// Arbitrary-precision decimal floating-point implementation built on top of Int.
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float/Private.h>- In
Float.c:9:
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float/Private.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>- In
Float.c:14:
static void float_normalize(Float *value);
static void float_replace(Float *dst, Float *src);
static bool float_try_from_u64_value(Float *out, u64 value, Allocator *alloc);- In
Float.c:15:
static void float_normalize(Float *value);
static void float_replace(Float *dst, Float *src);
static bool float_try_from_u64_value(Float *out, u64 value, Allocator *alloc);
static bool float_try_from_i64_value(Float *out, i64 value, Allocator *alloc);- In
Float.c:16:
static void float_normalize(Float *value);
static void float_replace(Float *dst, Float *src);
static bool float_try_from_u64_value(Float *out, u64 value, Allocator *alloc);
static bool float_try_from_i64_value(Float *out, i64 value, Allocator *alloc);
static bool float_try_from_int_value(Float *out, const Int *value);- In
Float.c:17:
static void float_replace(Float *dst, Float *src);
static bool float_try_from_u64_value(Float *out, u64 value, Allocator *alloc);
static bool float_try_from_i64_value(Float *out, i64 value, Allocator *alloc);
static bool float_try_from_int_value(Float *out, const Int *value);
static bool float_try_from_f32_value(Float *out, float value, Allocator *alloc);- In
Float.c:18:
static bool float_try_from_u64_value(Float *out, u64 value, Allocator *alloc);
static bool float_try_from_i64_value(Float *out, i64 value, Allocator *alloc);
static bool float_try_from_int_value(Float *out, const Int *value);
static bool float_try_from_f32_value(Float *out, float value, Allocator *alloc);
static bool float_try_from_f64_value(Float *out, double value, Allocator *alloc);- In
Float.c:19:
static bool float_try_from_i64_value(Float *out, i64 value, Allocator *alloc);
static bool float_try_from_int_value(Float *out, const Int *value);
static bool float_try_from_f32_value(Float *out, float value, Allocator *alloc);
static bool float_try_from_f64_value(Float *out, double value, Allocator *alloc);
static bool float_pow10(Int *out, u64 power, Allocator *alloc);- In
Float.c:20:
static bool float_try_from_int_value(Float *out, const Int *value);
static bool float_try_from_f32_value(Float *out, float value, Allocator *alloc);
static bool float_try_from_f64_value(Float *out, double value, Allocator *alloc);
static bool float_pow10(Int *out, u64 power, Allocator *alloc);
static bool float_scale_to_exponent(Float *value, i64 target_exponent);- In
Float.c:22:
static bool float_try_from_f64_value(Float *out, double value, Allocator *alloc);
static bool float_pow10(Int *out, u64 power, Allocator *alloc);
static bool float_scale_to_exponent(Float *value, i64 target_exponent);
static bool float_try_abs_compare(int *out, const Float *lhs, const Float *rhs);
static i64 float_add_i64_checked(i64 a, i64 b);- In
Float.c:23:
static bool float_pow10(Int *out, u64 power, Allocator *alloc);
static bool float_scale_to_exponent(Float *value, i64 target_exponent);
static bool float_try_abs_compare(int *out, const Float *lhs, const Float *rhs);
static i64 float_add_i64_checked(i64 a, i64 b);
static i64 float_sub_i64_checked(i64 a, i64 b);- In
Float.c:29:
static i64 float_add_i64_checked(i64 a, i64 b) {
if ((b > 0 && a > INT64_MAX - b) || (b < 0 && a < INT64_MIN - b)) {
LOG_FATAL("Float exponent overflow");
}- In
Float.c:37:
static i64 float_sub_i64_checked(i64 a, i64 b) {
if ((b > 0 && a < INT64_MIN + b) || (b < 0 && a > INT64_MAX + b)) {
LOG_FATAL("Float exponent overflow");
}- In
Float.c:55:
// is bit-perfect, where a decimal-text round-trip via a shortest-form
// formatter could lose information.
static bool float_try_from_ieee_bits(Float *out, u64 mantissa, int binexp, bool negative, Allocator *alloc) {
if (!out) {
LOG_FATAL("Invalid arguments");- In
Float.c:100:
}
static bool float_try_from_f32_value(Float *out, float value, Allocator *alloc) {
if (!out) {
LOG_FATAL("Invalid arguments");- In
Float.c:113:
u32 m = bits & 0x7FFFFFu;
if (e == 0xFFu) {
LOG_FATAL("Float from f32 does not represent finite values (Inf/NaN)");
}
u64 mantissa;- In
Float.c:129:
}
static bool float_try_from_f64_value(Float *out, double value, Allocator *alloc) {
if (!out) {
LOG_FATAL("Invalid arguments");- In
Float.c:142:
u64 m = bits & 0xFFFFFFFFFFFFFull;
if (e == 0x7FFull) {
LOG_FATAL("Float from f64 does not represent finite values (Inf/NaN)");
}
u64 mantissa;- In
Float.c:156:
}
static void float_replace(Float *dst, Float *src) {
FloatDeinit(dst);
*dst = *src;- In
Float.c:184:
}
static bool float_scale_to_exponent(Float *value, i64 target_exponent) {
ValidateFloat(value);- In
Float.c:218:
}
static bool float_try_abs_compare(int *out, const Float *lhs, const Float *rhs) {
ValidateFloat(lhs);
ValidateFloat(rhs);- In
Float.c:239:
// exponent; clone just that one and compare against the other's significand.
{
const Float *low = lhs->exponent < rhs->exponent ? lhs : rhs;
const Float *high = lhs->exponent < rhs->exponent ? rhs : lhs;
Float scaled = FloatInit(FloatAllocator(high));- In
Float.c:240:
{
const Float *low = lhs->exponent < rhs->exponent ? lhs : rhs;
const Float *high = lhs->exponent < rhs->exponent ? rhs : lhs;
Float scaled = FloatInit(FloatAllocator(high));
bool ok = false;- In
Float.c:241:
const Float *low = lhs->exponent < rhs->exponent ? lhs : rhs;
const Float *high = lhs->exponent < rhs->exponent ? rhs : lhs;
Float scaled = FloatInit(FloatAllocator(high));
bool ok = false;- In
Float.c:256:
}
static void float_normalize(Float *value) {
ValidateFloat(value);- In
Float.c:297:
}
bool FloatIsZero(const Float *value) {
ValidateFloat(value);
return IntIsZero(&value->significand);- In
Float.c:302:
}
bool FloatIsNegative(const Float *value) {
ValidateFloat(value);
return !FloatIsZero(value) && value->negative;- In
Float.c:307:
}
i64 FloatExponent(const Float *value) {
ValidateFloat(value);
return value->exponent;- In
Float.c:312:
}
Float FloatClone(const Float *value) {
Float clone;- In
Float.c:313:
Float FloatClone(const Float *value) {
Float clone;
ValidateFloat(value);- In
Float.c:321:
}
bool FloatTryClone(Float *out, const Float *value) {
if (!out || !value) {
LOG_FATAL("Invalid arguments");- In
Float.c:339:
}
static bool float_try_from_u64_value(Float *out, u64 value, Allocator *alloc) {
if (!out) {
LOG_FATAL("Invalid arguments");- In
Float.c:354:
}
static bool float_try_from_i64_value(Float *out, i64 value, Allocator *alloc) {
u64 magnitude = 0;- In
Float.c:375:
}
static bool float_try_from_int_value(Float *out, const Int *value) {
if (!out || !value) {
LOG_FATAL("Invalid arguments");- In
Float.c:391:
}
Float float_from_u64(u64 value, Allocator *alloc) {
Float result;- In
Float.c:392:
Float float_from_u64(u64 value, Allocator *alloc) {
Float result;
result = FloatInit(alloc);- In
Float.c:400:
}
Float float_from_i64(i64 value, Allocator *alloc) {
Float result = FloatInit(alloc);- In
Float.c:401:
Float float_from_i64(i64 value, Allocator *alloc) {
Float result = FloatInit(alloc);
(void)float_try_from_i64_value(&result, value, alloc);- In
Float.c:408:
}
Float float_from_int(const Int *value, Allocator *alloc) {
Float result;- In
Float.c:409:
Float float_from_int(const Int *value, Allocator *alloc) {
Float result;
ValidateInt(value);- In
Float.c:419:
}
Float float_from_f32(float value, Allocator *alloc) {
Float result = FloatInit(alloc);- In
Float.c:420:
Float float_from_f32(float value, Allocator *alloc) {
Float result = FloatInit(alloc);
(void)float_try_from_f32_value(&result, value, alloc);- In
Float.c:426:
}
Float float_from_f64(double value, Allocator *alloc) {
Float result = FloatInit(alloc);- In
Float.c:427:
Float float_from_f64(double value, Allocator *alloc) {
Float result = FloatInit(alloc);
(void)float_try_from_f64_value(&result, value, alloc);- In
Float.c:433:
}
bool FloatToInt(Int *result, const Float *value) {
ValidateInt(result);
ValidateFloat(value);- In
Float.c:488:
}
static bool float_try_from_str_impl(Float *out, Zstr text, size length) {
Float result;
Str digits;- In
Float.c:489:
static bool float_try_from_str_impl(Float *out, Zstr text, size length) {
Float result;
Str digits;
size pos = 0;- In
Float.c:521:
if (saw_decimal) {
if (fractional == INT64_MAX) {
LOG_ERROR("Float fractional exponent overflow");
goto fail;
}- In
Float.c:531:
if (ch == '.') {
if (saw_decimal) {
LOG_ERROR("Invalid Float format");
goto fail;
}- In
Float.c:547:
pos++;
if (pos >= length) {
LOG_ERROR("Invalid Float exponent");
goto fail;
}- In
Float.c:560:
parsed = ZstrToI64(exp_start, &endptr);
if (endptr == exp_start) {
LOG_ERROR("Invalid Float exponent");
goto fail;
}- In
Float.c:566:
exp_offset = (size)(endptr - text);
if (exp_offset != length) {
LOG_ERROR("Invalid Float exponent");
goto fail;
}- In
Float.c:575:
}
LOG_ERROR("Invalid Float format");
goto fail;
}- In
Float.c:580:
if (!saw_digit) {
LOG_ERROR("Invalid Float format");
goto fail;
}- In
Float.c:589:
if (explicit_exp < INT64_MIN + fractional) {
LOG_ERROR("Float exponent overflow");
goto fail;
}- In
Float.c:608:
}
bool float_try_from_str_zstr(Float *out, Zstr text) {
if (!out || !text) {
LOG_FATAL("Invalid arguments");- In
Float.c:615:
}
bool float_try_from_str_str(Float *out, const Str *text) {
if (!out || !text) {
LOG_FATAL("Invalid arguments");- In
Float.c:622:
}
Float float_from_str_zstr(Zstr text, Allocator *alloc) {
Float result = FloatInit(alloc);- In
Float.c:623:
Float float_from_str_zstr(Zstr text, Allocator *alloc) {
Float result = FloatInit(alloc);
(void)float_try_from_str_zstr(&result, text);- In
Float.c:629:
}
Float float_from_str_str(const Str *text, Allocator *alloc) {
Float result = FloatInit(alloc);- In
Float.c:630:
Float float_from_str_str(const Str *text, Allocator *alloc) {
Float result = FloatInit(alloc);
(void)float_try_from_str_str(&result, text);- In
Float.c:636:
}
bool float_try_to_str(Str *out, const Float *value, Allocator *alloc) {
Str digits;
Str result;- In
Float.c:719:
}
Str float_to_str(const Float *value, Allocator *alloc) {
Str result;- In
Float.c:731:
}
int float_compare_with_error(const Float *lhs, const Float *rhs, bool *error) {
int cmp = 0;- In
Float.c:758:
i32 float_compare(const void *lhs, const void *rhs) {
return float_compare_with_error((const Float *)lhs, (const Float *)rhs, NULL);
}- In
Float.c:765:
// inside the Int namespace.
u64 float_hash(const void *data, u32 size) {
const Float *value = (const Float *)data;
(void)size;- In
Float.c:783:
}
int float_compare_int_with_error(const Float *lhs, const Int *rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:784:
int float_compare_int_with_error(const Float *lhs, const Int *rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:805:
}
int float_compare_int(const Float *lhs, const Int *rhs) {
return float_compare_int_with_error(lhs, rhs, NULL);
}- In
Float.c:809:
}
int float_compare_u64_with_error(const Float *lhs, u64 rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:810:
int float_compare_u64_with_error(const Float *lhs, u64 rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:830:
}
int float_compare_u64(const Float *lhs, u64 rhs) {
return float_compare_u64_with_error(lhs, rhs, NULL);
}- In
Float.c:834:
}
int float_compare_i64_with_error(const Float *lhs, i64 rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:835:
int float_compare_i64_with_error(const Float *lhs, i64 rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:855:
}
int float_compare_i64(const Float *lhs, i64 rhs) {
return float_compare_i64_with_error(lhs, rhs, NULL);
}- In
Float.c:859:
}
int float_compare_f32_with_error(const Float *lhs, float rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:860:
int float_compare_f32_with_error(const Float *lhs, float rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:880:
}
int float_compare_f32(const Float *lhs, float rhs) {
return float_compare_f32_with_error(lhs, rhs, NULL);
}- In
Float.c:884:
}
int float_compare_f64_with_error(const Float *lhs, double rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:885:
int float_compare_f64_with_error(const Float *lhs, double rhs, bool *error) {
Float rhs_value = FloatInit(FloatAllocator(lhs));
int cmp = 0;- In
Float.c:905:
}
int float_compare_f64(const Float *lhs, double rhs) {
return float_compare_f64_with_error(lhs, rhs, NULL);
}- In
Float.c:909:
}
void FloatNegate(Float *value) {
ValidateFloat(value);- In
Float.c:917:
}
void FloatAbs(Float *value) {
ValidateFloat(value);
value->negative = false;- In
Float.c:922:
}
bool float_add(Float *result, const Float *a, const Float *b) {
Float lhs;
Float rhs;- In
Float.c:923:
bool float_add(Float *result, const Float *a, const Float *b) {
Float lhs;
Float rhs;
Float temp;- In
Float.c:924:
bool float_add(Float *result, const Float *a, const Float *b) {
Float lhs;
Float rhs;
Float temp;
i64 exp = 0;- In
Float.c:925:
Float lhs;
Float rhs;
Float temp;
i64 exp = 0;- In
Float.c:991:
}
bool float_add_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:992:
bool float_add_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_int_value(&rhs, b)) {- In
Float.c:1002:
}
bool float_add_u64(Float *result, const Float *a, u64 b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1003:
bool float_add_u64(Float *result, const Float *a, u64 b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1013:
}
bool float_add_i64(Float *result, const Float *a, i64 b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1014:
bool float_add_i64(Float *result, const Float *a, i64 b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1024:
}
bool float_add_f32(Float *result, const Float *a, float b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1025:
bool float_add_f32(Float *result, const Float *a, float b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1035:
}
bool float_add_f64(Float *result, const Float *a, double b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1036:
bool float_add_f64(Float *result, const Float *a, double b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1046:
}
bool float_sub(Float *result, const Float *a, const Float *b) {
Float rhs = FloatInit(FloatAllocator(b));- In
Float.c:1047:
bool float_sub(Float *result, const Float *a, const Float *b) {
Float rhs = FloatInit(FloatAllocator(b));
ValidateFloat(result);- In
Float.c:1062:
}
bool float_sub_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1063:
bool float_sub_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_int_value(&rhs, b)) {- In
Float.c:1073:
}
bool float_sub_u64(Float *result, const Float *a, u64 b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1074:
bool float_sub_u64(Float *result, const Float *a, u64 b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1084:
}
bool float_sub_i64(Float *result, const Float *a, i64 b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1085:
bool float_sub_i64(Float *result, const Float *a, i64 b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1095:
}
bool float_sub_f32(Float *result, const Float *a, float b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1096:
bool float_sub_f32(Float *result, const Float *a, float b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1106:
}
bool float_sub_f64(Float *result, const Float *a, double b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1107:
bool float_sub_f64(Float *result, const Float *a, double b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1117:
}
bool float_mul(Float *result, const Float *a, const Float *b) {
Float temp = FloatInit(FloatAllocator(result));- In
Float.c:1118:
bool float_mul(Float *result, const Float *a, const Float *b) {
Float temp = FloatInit(FloatAllocator(result));
ValidateFloat(result);- In
Float.c:1136:
}
bool float_mul_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1137:
bool float_mul_int(Float *result, const Float *a, const Int *b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_int_value(&rhs, b)) {- In
Float.c:1147:
}
bool float_mul_u64(Float *result, const Float *a, u64 b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1148:
bool float_mul_u64(Float *result, const Float *a, u64 b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_u64_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1158:
}
bool float_mul_i64(Float *result, const Float *a, i64 b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1159:
bool float_mul_i64(Float *result, const Float *a, i64 b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_i64_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1169:
}
bool float_mul_f32(Float *result, const Float *a, float b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1170:
bool float_mul_f32(Float *result, const Float *a, float b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_f32_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1180:
}
bool float_mul_f64(Float *result, const Float *a, double b) {
Float rhs = FloatInit(FloatAllocator(result));- In
Float.c:1181:
bool float_mul_f64(Float *result, const Float *a, double b) {
Float rhs = FloatInit(FloatAllocator(result));
if (!float_try_from_f64_value(&rhs, b, FloatAllocator(result))) {- In
Float.c:1191:
}
bool float_div(Float *result, const Float *a, const Float *b, u64 precision) {
Float temp = FloatInit(FloatAllocator(result));
Int scale = IntInit(FloatAllocator(result));- In
Float.c:1192:
bool float_div(Float *result, const Float *a, const Float *b, u64 precision) {
Float temp = FloatInit(FloatAllocator(result));
Int scale = IntInit(FloatAllocator(result));
Int scaled = IntInit(FloatAllocator(result));- In
Float.c:1205:
}
if (FloatIsZero(a)) {
Float zero = FloatInit(FloatAllocator(result));
FloatDeinit(result);- In
Float.c:1236:
}
bool float_div_int(Float *result, const Float *a, const Int *b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Float.c:1237:
bool float_div_int(Float *result, const Float *a, const Int *b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Float.c:1248:
}
bool float_div_u64(Float *result, const Float *a, u64 b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Float.c:1249:
bool float_div_u64(Float *result, const Float *a, u64 b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Float.c:1260:
}
bool float_div_i64(Float *result, const Float *a, i64 b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Float.c:1261:
bool float_div_i64(Float *result, const Float *a, i64 b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Float.c:1272:
}
bool float_div_f32(Float *result, const Float *a, float b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Float.c:1273:
bool float_div_f32(Float *result, const Float *a, float b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Float.c:1284:
}
bool float_div_f64(Float *result, const Float *a, double b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Float.c:1285:
bool float_div_f64(Float *result, const Float *a, double b, u64 precision) {
Float rhs = FloatInit(FloatAllocator(result));
bool ok = false;- In
Compare.c:3:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/Map.h>- In
Compare.c:46:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1.23", &alloc.base);
Float b = FloatFromStr("123e-2", &alloc.base);
Float c = FloatFromStr("-1.23", &alloc.base);- In
Compare.c:47:
Float a = FloatFromStr("1.23", &alloc.base);
Float b = FloatFromStr("123e-2", &alloc.base);
Float c = FloatFromStr("-1.23", &alloc.base);- In
Compare.c:48:
Float a = FloatFromStr("1.23", &alloc.base);
Float b = FloatFromStr("123e-2", &alloc.base);
Float c = FloatFromStr("-1.23", &alloc.base);
bool result = FloatCompare(&a, &b) == 0;- In
Compare.c:67:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float c = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);- In
Compare.c:68:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float c = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);- In
Compare.c:69:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float c = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
bool result = FloatLT(&a, &b);- In
Compare.c:88:
DefaultAllocator alloc = DefaultAllocatorInit();
Float large = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float negative_large = FloatFromStr("-" FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float small = FloatFromStr("2.5", &alloc.base);- In
Compare.c:89:
Float large = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float negative_large = FloatFromStr("-" FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float small = FloatFromStr("2.5", &alloc.base);- In
Compare.c:90:
Float large = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float negative_large = FloatFromStr("-" FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float small = FloatFromStr("2.5", &alloc.base);
bool result = FloatGT(&large, &small);- In
Compare.c:104:
bool test_float_compare_wrappers(void) {
WriteFmt("Testing Float compare macros\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Compare.c:108:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("-2", &alloc.base);
Float b = FloatFromStr("0.5", &alloc.base);
Float expected = FloatFromStr("5e-1", &alloc.base);- In
Compare.c:109:
Float a = FloatFromStr("-2", &alloc.base);
Float b = FloatFromStr("0.5", &alloc.base);
Float expected = FloatFromStr("5e-1", &alloc.base);- In
Compare.c:110:
Float a = FloatFromStr("-2", &alloc.base);
Float b = FloatFromStr("0.5", &alloc.base);
Float expected = FloatFromStr("5e-1", &alloc.base);
bool result = FloatLT(&a, &b);- In
Compare.c:131:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("12.5", &alloc.base);
Float same = FloatFromStr("12.5", &alloc.base);
Int whole = IntFrom(12, &alloc.base);- In
Compare.c:132:
Float value = FloatFromStr("12.5", &alloc.base);
Float same = FloatFromStr("12.5", &alloc.base);
Int whole = IntFrom(12, &alloc.base);
Int next = IntFrom(13, &alloc.base);- In
Compare.c:164:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1.23", &alloc.base);
Float b = FloatFromStr("123e-2", &alloc.base);
Float zero1 = FloatFromStr("0", &alloc.base);- In
Compare.c:165:
Float a = FloatFromStr("1.23", &alloc.base);
Float b = FloatFromStr("123e-2", &alloc.base);
Float zero1 = FloatFromStr("0", &alloc.base);
Float zero2 = FloatFromStr("0", &alloc.base);- In
Compare.c:166:
Float a = FloatFromStr("1.23", &alloc.base);
Float b = FloatFromStr("123e-2", &alloc.base);
Float zero1 = FloatFromStr("0", &alloc.base);
Float zero2 = FloatFromStr("0", &alloc.base);- In
Compare.c:167:
Float b = FloatFromStr("123e-2", &alloc.base);
Float zero1 = FloatFromStr("0", &alloc.base);
Float zero2 = FloatFromStr("0", &alloc.base);
bool result = (float_hash(&a, 0) == float_hash(&b, 0));- In
Compare.c:187:
DefaultAllocator alloc = DefaultAllocatorInit();
Float pos = FloatFromStr("1.5e3", &alloc.base);
Float neg = FloatFromStr("-1.5e3", &alloc.base);
Float small = FloatFromStr("1.5e2", &alloc.base);- In
Compare.c:188:
Float pos = FloatFromStr("1.5e3", &alloc.base);
Float neg = FloatFromStr("-1.5e3", &alloc.base);
Float small = FloatFromStr("1.5e2", &alloc.base);
Float zero = FloatFromStr("0", &alloc.base);- In
Compare.c:189:
Float pos = FloatFromStr("1.5e3", &alloc.base);
Float neg = FloatFromStr("-1.5e3", &alloc.base);
Float small = FloatFromStr("1.5e2", &alloc.base);
Float zero = FloatFromStr("0", &alloc.base);
Float one = FloatFromStr("1", &alloc.base);- In
Compare.c:190:
Float neg = FloatFromStr("-1.5e3", &alloc.base);
Float small = FloatFromStr("1.5e2", &alloc.base);
Float zero = FloatFromStr("0", &alloc.base);
Float one = FloatFromStr("1", &alloc.base);- In
Compare.c:191:
Float small = FloatFromStr("1.5e2", &alloc.base);
Float zero = FloatFromStr("0", &alloc.base);
Float one = FloatFromStr("1", &alloc.base);
u64 h_pos = float_hash(&pos, 0);- In
Compare.c:217:
// the GenericHash / GenericCompare-shaped helpers wire in directly.
bool test_float_hash_as_map_key(void) {
WriteFmt("Testing float_hash as Map<Float, u64> key\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Compare.c:221:
DefaultAllocator alloc = DefaultAllocatorInit();
Map(Float, u64) counts = MapInit(float_hash, float_compare, &alloc);
Float k1 = FloatFromStr("3.14", &alloc.base);- In
Compare.c:223:
Map(Float, u64) counts = MapInit(float_hash, float_compare, &alloc);
Float k1 = FloatFromStr("3.14", &alloc.base);
Float k2 = FloatFromStr("2.71", &alloc.base);
MapInsertR(&counts, k1, 1u);- In
Compare.c:224:
Float k1 = FloatFromStr("3.14", &alloc.base);
Float k2 = FloatFromStr("2.71", &alloc.base);
MapInsertR(&counts, k1, 1u);
MapInsertR(&counts, k2, 2u);- In
Compare.c:228:
MapInsertR(&counts, k2, 2u);
Float probe = FloatFromStr("314e-2", &alloc.base); // same value as k1
u64 *got = MapGetFirstPtr(&counts, probe);
Float missing = FloatFromStr("9.99", &alloc.base);- In
Compare.c:230:
Float probe = FloatFromStr("314e-2", &alloc.base); // same value as k1
u64 *got = MapGetFirstPtr(&counts, probe);
Float missing = FloatFromStr("9.99", &alloc.base);
u64 *gone = MapGetFirstPtr(&counts, missing);- In
Compare.c:252:
DefaultAllocator alloc = DefaultAllocatorInit();
Float small = FloatFrom((u64)5, &alloc.base);
int cmp = FloatCompare(&small, (u64)100);
bool ok = cmp < 0;- In
Compare.c:266:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFrom((u64)42, &alloc.base);
int cmp = FloatCompare(&value, (u64)42);
bool ok = cmp == 0;- In
Compare.c:288:
DefaultAllocator alloc = DefaultAllocatorInit();
Float v = FloatFromStr("3", &alloc.base);
Int i3 = IntFrom(3, &alloc.base);
bool err = true;- In
Compare.c:321:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFrom(5.0, &alloc.base);
Float b = FloatFrom(0.0, &alloc.base);- In
Compare.c:322:
Float a = FloatFrom(5.0, &alloc.base);
Float b = FloatFrom(0.0, &alloc.base);
int cmp = FloatCompare(&a, &b);- In
Compare.c:342:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFrom(0.0, &alloc.base);
Float b = FloatFrom(5.0, &alloc.base);- In
Compare.c:343:
Float a = FloatFrom(0.0, &alloc.base);
Float b = FloatFrom(5.0, &alloc.base);
int cmp = FloatCompare(&a, &b);- In
Compare.c:359:
// real ordering. Asserting the exact ordering value (+1) catches it.
static bool test_m6_compare_u64_greater(void) {
WriteFmt("Testing FloatCompare(Float, u64) returns +1 when greater\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Compare.c:363:
DefaultAllocator alloc = DefaultAllocatorInit();
Float lhs = FloatFromStr("5", &alloc.base);
int cmp = FloatCompare(&lhs, (u64)3);- In
Compare.c:375:
// Equality path: real code returns 0. A 42 return would fail this exact check.
static bool test_m6_compare_u64_equal(void) {
WriteFmt("Testing FloatCompare(Float, u64) returns 0 when equal\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Compare.c:379:
DefaultAllocator alloc = DefaultAllocatorInit();
Float lhs = FloatFromStr("5", &alloc.base);
int cmp = FloatCompare(&lhs, (u64)5);- In
Compare.c:391:
// Less-than path: real code returns -1. The mutated return of 42 fails this.
static bool test_m6_compare_u64_less(void) {
WriteFmt("Testing FloatCompare(Float, u64) returns -1 when less\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Compare.c:395:
DefaultAllocator alloc = DefaultAllocatorInit();
Float lhs = FloatFromStr("5", &alloc.base);
int cmp = FloatCompare(&lhs, (u64)9);- In
Compare.c:409:
// while also pinning the error contract on the success path.
static bool test_m6_compare_u64_no_error_flag(void) {
WriteFmt("Testing FloatCompare(Float, u64, &error) clears error on success\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Compare.c:413:
DefaultAllocator alloc = DefaultAllocatorInit();
Float lhs = FloatFromStr("7", &alloc.base);
bool error = true;
int cmp = FloatCompare(&lhs, (u64)2, &error);- In
Compare.c:429:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1.5", &alloc.base);
Float b = FloatFromStr("2.5", &alloc.base);
bool err = true;- In
Compare.c:430:
Float a = FloatFromStr("1.5", &alloc.base);
Float b = FloatFromStr("2.5", &alloc.base);
bool err = true;- In
Compare.c:448:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("3", &alloc.base); // non-zero
Float b = FloatFromStr("0", &alloc.base); // zero
- In
Compare.c:449:
Float a = FloatFromStr("3", &alloc.base); // non-zero
Float b = FloatFromStr("0", &alloc.base); // zero
int cmp = FloatCompare(&a, &b);- In
Compare.c:466:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("0", &alloc.base); // zero
Float b = FloatFromStr("4", &alloc.base); // non-zero
- In
Compare.c:467:
Float a = FloatFromStr("0", &alloc.base); // zero
Float b = FloatFromStr("4", &alloc.base); // non-zero
int cmp = FloatCompare(&a, &b);- In
Compare.c:484:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("-5", &alloc.base);
Float b = FloatFromStr("-2", &alloc.base);- In
Compare.c:485:
Float a = FloatFromStr("-5", &alloc.base);
Float b = FloatFromStr("-2", &alloc.base);
int cmp = FloatCompare(&a, &b); // -5 < -2 -> -1
- In
Compare.c:501:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("-2", &alloc.base);
Float b = FloatFromStr("-5", &alloc.base);- In
Compare.c:502:
Float a = FloatFromStr("-2", &alloc.base);
Float b = FloatFromStr("-5", &alloc.base);
int cmp = FloatCompare(&a, &b); // -2 > -5 -> 1
- In
Compare.c:524:
DefaultAllocator alloc = DefaultAllocatorInit();
Float lhs = FloatFromStr("7", &alloc.base);
Int less = IntFrom(3, &alloc.base);
Int same = IntFrom(7, &alloc.base);- In
Compare.c:559:
DefaultAllocator alloc = DefaultAllocatorInit();
Float lhs = FloatFromStr("-4", &alloc.base);
bool error = true;- In
Compare.c:588:
DefaultAllocator alloc = DefaultAllocatorInit();
Float lhs = FloatFromStr("0.5", &alloc.base);
bool error = true;- In
Compare.c:617:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1", &alloc.base); // significand 1, exponent 0
Float b = FloatFromStr("1e2", &alloc.base); // significand 1, exponent 2
- In
Compare.c:618:
Float a = FloatFromStr("1", &alloc.base); // significand 1, exponent 0
Float b = FloatFromStr("1e2", &alloc.base); // significand 1, exponent 2
// Construction guard: identical significand, exponents differ only in low
- In
Compare.c:641:
DefaultAllocator alloc = DefaultAllocatorInit();
Float pos = FloatFromStr("3.14", &alloc.base);
Float neg = FloatFromStr("-3.14", &alloc.base);- In
Compare.c:642:
Float pos = FloatFromStr("3.14", &alloc.base);
Float neg = FloatFromStr("-3.14", &alloc.base);
bool distinct = float_hash(&pos, 0) != float_hash(&neg, 0);- In
Compare.c:659:
DefaultAllocator alloc = DefaultAllocatorInit();
Float pos = FloatFromStr("2", &alloc.base);
Float neg = FloatFromStr("-2", &alloc.base);- In
Compare.c:660:
Float pos = FloatFromStr("2", &alloc.base);
Float neg = FloatFromStr("-2", &alloc.base);
bool distinct = float_hash(&pos, 0) != float_hash(&neg, 0);- In
Compare.c:681:
DefaultAllocator alloc = DefaultAllocatorInit();
Float one = FloatFromStr("1", &alloc.base);
// Real float_hash(1) == 8811625884996682770; the i<=sizeof mutant yields
- In
Compare.c:699:
DefaultAllocator alloc = DefaultAllocatorInit();
Float zero = FloatFromStr("0", &alloc.base);
// Real float_hash(0) == 16357866887873635513; the i<=sizeof mutant yields
- In
Compare.c:720:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float b = FloatFromStr("1.25", &dbg.base);- In
Compare.c:721:
Float a = FloatFromStr("1.5", &dbg.base);
Float b = FloatFromStr("1.25", &dbg.base);
int cmp = FloatCompare(&a, &b);- In
Compare.c:741:
bool test_compare_int_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("3.5", &dbg.base);
Int b = IntFrom(3, &dbg.base);- In
Compare.c:757:
bool test_compare_u64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("3.5", &dbg.base);
int cmp = FloatCompare(&a, 3u);- In
Compare.c:771:
bool test_compare_i64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("-3.5", &dbg.base);
int cmp = FloatCompare(&a, -3);- In
Compare.c:785:
bool test_compare_f32_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("3.5", &dbg.base);
int cmp = FloatCompare(&a, 3.25f);- In
Compare.c:799:
bool test_compare_f64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("3.5", &dbg.base);
int cmp = FloatCompare(&a, 3.25);- In
Compare.c:811:
int main(void) {
WriteFmt("[INFO] Starting Float.Compare tests\n\n");
TestFunction tests[] = {- In
Compare.c:853:
int total_tests = sizeof(tests) / sizeof(tests[0]);
return run_test_suite(tests, total_tests, NULL, 0, "Float.Compare");
}- In
Type.c:3:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>- In
Type.c:19:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatInit(&alloc.base);
bool result = FloatIsZero(&value);- In
Type.c:35:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("-123.45", &alloc.base);
FloatClear(&value);- In
Type.c:53:
DefaultAllocator alloc = DefaultAllocatorInit();
Float original = FloatFromStr("-12.5", &alloc.base);
Float clone = FloatClone(&original);
Float expected = FloatFromStr("-12.5", &alloc.base);- In
Type.c:54:
Float original = FloatFromStr("-12.5", &alloc.base);
Float clone = FloatClone(&original);
Float expected = FloatFromStr("-12.5", &alloc.base);
Str text = FloatToStr(&clone);- In
Type.c:55:
Float original = FloatFromStr("-12.5", &alloc.base);
Float clone = FloatClone(&original);
Float expected = FloatFromStr("-12.5", &alloc.base);
Str text = FloatToStr(&clone);- In
Type.c:85:
// a non-trivial three-bit magnitude that exercises the clone-vs-original
// equality check below.
Float original = FloatFromStr("-0.005", &alloc.base);
Float clone = FloatClone(&original);- In
Type.c:87:
Float original = FloatFromStr("-0.005", &alloc.base);
Float clone = FloatClone(&original);
bool result = FloatEQ(&clone, &original) && FloatAllocator(&clone) == FloatAllocator(&original) &&- In
Type.c:111:
DefaultAllocator alloc = DefaultAllocatorInit();
Float zero = FloatFromStr("0", &alloc.base);
Float big = FloatFromStr("3e5", &alloc.base);
Float r = FloatInit(&alloc.base);- In
Type.c:112:
Float zero = FloatFromStr("0", &alloc.base);
Float big = FloatFromStr("3e5", &alloc.base);
Float r = FloatInit(&alloc.base);- In
Type.c:113:
Float zero = FloatFromStr("0", &alloc.base);
Float big = FloatFromStr("3e5", &alloc.base);
Float r = FloatInit(&alloc.base);
bool ok = FloatMul(&r, &zero, &big);- In
Type.c:145:
DefaultAllocator alloc = DefaultAllocatorInit();
Float normalized_zero = FloatFromStr("0", &alloc.base);
Float canonical_zero = FloatInit(&alloc.base);- In
Type.c:146:
Float normalized_zero = FloatFromStr("0", &alloc.base);
Float canonical_zero = FloatInit(&alloc.base);
// Sanity: both are zero.
- In
Type.c:174:
DefaultAllocator alloc = DefaultAllocatorInit();
Float neg = FloatFromStr("-5", &alloc.base);
Int out = IntInit(&alloc.base);- In
Type.c:202:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = {
.negative = false,
.significand = IntFromStr("50", &alloc.base),- In
Type.c:227:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("120", &alloc.base);
Int result = IntInit(&alloc.base);- In
Type.c:248:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("0", &alloc.base);
Int result = IntFromStr("999", &alloc.base);- In
Type.c:266:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("-7", &alloc.base);
Int result = IntInit(&alloc.base);- In
Type.c:286:
DefaultAllocator alloc = DefaultAllocatorInit();
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "1E2");
Str text = StrInit(&alloc.base);- In
Type.c:310:
DefaultAllocator alloc = DefaultAllocatorInit();
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "1e-9223372036854775808");
const i64 minexp = (i64)(-9223372036854775807LL - 1);- In
Type.c:334:
double two_pow_60 = 1152921504606846976.0; // 2^60, exact in f64
Float value = FloatFrom(two_pow_60, &alloc.base);
Str text = FloatToStr(&value);- In
Type.c:350:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("100", &alloc.base); // exp 2
Float b = FloatFromStr("0.1", &alloc.base); // exp -1
Float r = FloatInit(&alloc.base);- In
Type.c:351:
Float a = FloatFromStr("100", &alloc.base); // exp 2
Float b = FloatFromStr("0.1", &alloc.base); // exp -1
Float r = FloatInit(&alloc.base);
Str t = StrInit(&alloc.base);- In
Type.c:352:
Float a = FloatFromStr("100", &alloc.base); // exp 2
Float b = FloatFromStr("0.1", &alloc.base); // exp -1
Float r = FloatInit(&alloc.base);
Str t = StrInit(&alloc.base);- In
Type.c:372:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("12.5", &alloc.base); // exp -1
Float z = FloatFromStr("0", &alloc.base); // exp 0, zero
Float r = FloatInit(&alloc.base);- In
Type.c:373:
Float a = FloatFromStr("12.5", &alloc.base); // exp -1
Float z = FloatFromStr("0", &alloc.base); // exp 0, zero
Float r = FloatInit(&alloc.base);
Str t = StrInit(&alloc.base);- In
Type.c:374:
Float a = FloatFromStr("12.5", &alloc.base); // exp -1
Float z = FloatFromStr("0", &alloc.base); // exp 0, zero
Float r = FloatInit(&alloc.base);
Str t = StrInit(&alloc.base);- In
Type.c:390:
int main(void) {
WriteFmt("[INFO] Starting Float.Type tests\n\n");
TestFunction tests[] = {- In
Type.c:412:
int total_tests = sizeof(tests) / sizeof(tests[0]);
return run_test_suite(tests, total_tests, NULL, 0, "Float.Type");
}- In
Math.c:4:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>- In
Math.c:76:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("12.5", &alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:100:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1.2", &alloc.base);
Float b = FloatFromStr("0.03", &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:101:
Float a = FloatFromStr("1.2", &alloc.base);
Float b = FloatFromStr("0.03", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:102:
Float a = FloatFromStr("1.2", &alloc.base);
Float b = FloatFromStr("0.03", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:123:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:124:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:125:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:146:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1.25", &alloc.base);
Float b = FloatFromStr("0.75", &alloc.base);
Int whole = IntFrom(2, &alloc.base);- In
Math.c:147:
Float a = FloatFromStr("1.25", &alloc.base);
Float b = FloatFromStr("0.75", &alloc.base);
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:149:
Float b = FloatFromStr("0.75", &alloc.base);
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:195:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1.5", &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:196:
Float a = FloatFromStr("1.5", &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:197:
Float a = FloatFromStr("1.5", &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:218:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_THREES, &alloc.base);
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:219:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_THREES, &alloc.base);
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:220:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_THREES, &alloc.base);
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:241:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("5.5", &alloc.base);
Float b = FloatFromStr("0.5", &alloc.base);
Int whole = IntFrom(2, &alloc.base);- In
Math.c:242:
Float a = FloatFromStr("5.5", &alloc.base);
Float b = FloatFromStr("0.5", &alloc.base);
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:244:
Float b = FloatFromStr("0.5", &alloc.base);
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:285:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("12.5", &alloc.base);
Float b = FloatFromStr("-0.2", &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:286:
Float a = FloatFromStr("12.5", &alloc.base);
Float b = FloatFromStr("-0.2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:287:
Float a = FloatFromStr("12.5", &alloc.base);
Float b = FloatFromStr("-0.2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:308:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:309:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:310:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:331:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1.5", &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Int whole = IntFrom(2, &alloc.base);- In
Math.c:332:
Float a = FloatFromStr("1.5", &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:334:
Float b = FloatFromStr("2", &alloc.base);
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:375:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1", &alloc.base);
Float b = FloatFromStr("8", &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:376:
Float a = FloatFromStr("1", &alloc.base);
Float b = FloatFromStr("8", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:377:
Float a = FloatFromStr("1", &alloc.base);
Float b = FloatFromStr("8", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:398:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:399:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:400:
Float a = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:421:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("7.5", &alloc.base);
Float b = FloatFromStr("2.5", &alloc.base);
Int whole = IntFrom(3, &alloc.base);- In
Math.c:422:
Float a = FloatFromStr("7.5", &alloc.base);
Float b = FloatFromStr("2.5", &alloc.base);
Int whole = IntFrom(3, &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:424:
Float b = FloatFromStr("2.5", &alloc.base);
Int whole = IntFrom(3, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:470:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1", &alloc.base);
Float b = FloatInit(&alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:471:
Float a = FloatFromStr("1", &alloc.base);
Float b = FloatInit(&alloc.base);
Float r = FloatInit(&alloc.base);
bool ok;- In
Math.c:472:
Float a = FloatFromStr("1", &alloc.base);
Float b = FloatInit(&alloc.base);
Float r = FloatInit(&alloc.base);
bool ok;- In
Math.c:496:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("-2", &alloc.base);
Float b = FloatFromStr("5", &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:497:
Float a = FloatFromStr("-2", &alloc.base);
Float b = FloatFromStr("5", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:498:
Float a = FloatFromStr("-2", &alloc.base);
Float b = FloatFromStr("5", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:524:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("2", &alloc.base);
Float b = FloatFromStr("-5", &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:525:
Float a = FloatFromStr("2", &alloc.base);
Float b = FloatFromStr("-5", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:526:
Float a = FloatFromStr("2", &alloc.base);
Float b = FloatFromStr("-5", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:550:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("-0.25", &alloc.base);
Float b = FloatFromStr("1.00", &alloc.base);
Float result_value = FloatInit(&alloc.base);- In
Math.c:551:
Float a = FloatFromStr("-0.25", &alloc.base);
Float b = FloatFromStr("1.00", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:552:
Float a = FloatFromStr("-0.25", &alloc.base);
Float b = FloatFromStr("1.00", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:577:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("3e" EXP_HALF_LO, &alloc.base);
Float b = FloatFromStr("3e" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:578:
Float a = FloatFromStr("3e" EXP_HALF_LO, &alloc.base);
Float b = FloatFromStr("3e" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:579:
Float a = FloatFromStr("3e" EXP_HALF_LO, &alloc.base);
Float b = FloatFromStr("3e" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);
bool ok = FloatMul(&r, &a, &b);- In
Math.c:599:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float b = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:600:
Float a = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float b = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:601:
Float a = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float b = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);
bool ok = FloatMul(&r, &a, &b);- In
Math.c:622:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float b = FloatFromStr("3e" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:623:
Float a = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float b = FloatFromStr("3e" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:624:
Float a = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float b = FloatFromStr("3e" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);
bool ok = FloatDiv(&r, &a, &b, 0);- In
Math.c:644:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("3e" EXP_HALF_LO, &alloc.base);
Float b = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:645:
Float a = FloatFromStr("3e" EXP_HALF_LO, &alloc.base);
Float b = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:646:
Float a = FloatFromStr("3e" EXP_HALF_LO, &alloc.base);
Float b = FloatFromStr("3e-" EXP_HALF_HI, &alloc.base);
Float r = FloatInit(&alloc.base);
bool ok = FloatDiv(&r, &a, &b, 0);- In
Math.c:667:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1", &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:668:
Float a = FloatFromStr("1", &alloc.base);
Float r = FloatInit(&alloc.base);
bool ok = !FloatDiv(&r, &a, 0.0, 4);- In
Math.c:687:
DefaultAllocator alloc = DefaultAllocatorInit();
Float neg = FloatFrom(-1.0f, &alloc.base);
Float pos = FloatFrom(1.0f, &alloc.base);- In
Math.c:688:
Float neg = FloatFrom(-1.0f, &alloc.base);
Float pos = FloatFrom(1.0f, &alloc.base);
bool result = FloatIsNegative(&neg) && !FloatIsNegative(&pos);- In
Math.c:709:
// 0x1p-149f: e == 0, m == 1 -> smallest positive f32 subnormal.
Float tiny = FloatFrom(0x1p-149f, &alloc.base);
bool result = FloatLT(&tiny, 1.0f) && FloatGT(&tiny, 0.0f);- In
Math.c:727:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFrom(0x1p-149f, &alloc.base); // m == 1
Float b = FloatFrom(0x3p-149f, &alloc.base); // m == 3
- In
Math.c:728:
Float a = FloatFrom(0x1p-149f, &alloc.base); // m == 1
Float b = FloatFrom(0x3p-149f, &alloc.base); // m == 3
bool result = FloatNE(&a, &b);- In
Math.c:745:
DefaultAllocator alloc = DefaultAllocatorInit();
Float neg = FloatFrom(-1.0, &alloc.base);
Float pos = FloatFrom(1.0, &alloc.base);- In
Math.c:746:
Float neg = FloatFrom(-1.0, &alloc.base);
Float pos = FloatFrom(1.0, &alloc.base);
bool result = FloatIsNegative(&neg) && !FloatIsNegative(&pos);- In
Math.c:765:
// 0x1p-1074: e == 0, m == 1 -> smallest positive f64 subnormal.
Float tiny = FloatFrom(0x1p-1074, &alloc.base);
bool result = FloatLT(&tiny, 1.0) && FloatGT(&tiny, 0.0);- In
Math.c:782:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFrom(0x1p-1074, &alloc.base); // m == 1
Float b = FloatFrom(0x3p-1074, &alloc.base); // m == 3
- In
Math.c:783:
Float a = FloatFrom(0x1p-1074, &alloc.base); // m == 1
Float b = FloatFrom(0x3p-1074, &alloc.base); // m == 3
bool result = FloatNE(&a, &b);- In
Math.c:798:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("6", &alloc.base);
Float result = FloatInit(&alloc.base);
Int zero = IntFrom(0u, &alloc.base);- In
Math.c:799:
Float a = FloatFromStr("6", &alloc.base);
Float result = FloatInit(&alloc.base);
Int zero = IntFrom(0u, &alloc.base);- In
Math.c:819:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("6", &alloc.base);
Float result = FloatInit(&alloc.base);- In
Math.c:820:
Float a = FloatFromStr("6", &alloc.base);
Float result = FloatInit(&alloc.base);
bool ok = FloatDiv(&result, &a, (signed long long)0, 4);- In
Math.c:837:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("6", &alloc.base);
Float result = FloatInit(&alloc.base);- In
Math.c:838:
Float a = FloatFromStr("6", &alloc.base);
Float result = FloatInit(&alloc.base);
bool ok = FloatDiv(&result, &a, 0.0f, 4);- In
Math.c:858:
DefaultAllocator alloc = DefaultAllocatorInit();
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "+5");
Str text = StrInit(&alloc.base);- In
Math.c:880:
DefaultAllocator alloc = DefaultAllocatorInit();
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "19");
Str text = StrInit(&alloc.base);- In
Math.c:899:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("6", &alloc.base);
Float b = FloatFromStr("3", &alloc.base);
Float quotient = FloatInit(&alloc.base);- In
Math.c:900:
Float a = FloatFromStr("6", &alloc.base);
Float b = FloatFromStr("3", &alloc.base);
Float quotient = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:901:
Float a = FloatFromStr("6", &alloc.base);
Float b = FloatFromStr("3", &alloc.base);
Float quotient = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);- In
Math.c:927:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("7.5", &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:928:
Float a = FloatFromStr("7.5", &alloc.base);
Float r = FloatInit(&alloc.base);
bool ok = (FloatDiv(&r, &a, 0u, 4) == false);- In
Math.c:948:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("100", &alloc.base);
Float r = FloatInit(&alloc.base);- In
Math.c:949:
Float a = FloatFromStr("100", &alloc.base);
Float r = FloatInit(&alloc.base);
bool ok = !FloatDiv(&r, &a, 0u, 4);- In
Math.c:969:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("7.5", &alloc.base);
Float r = FloatInit(&alloc.base);
Str text;- In
Math.c:970:
Float a = FloatFromStr("7.5", &alloc.base);
Float r = FloatInit(&alloc.base);
Str text;- In
Math.c:994:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base); // exp -1
Float b = FloatFromStr("0.025", &dbg.base); // exp -3 -> scaling occurs
Float r = FloatInit(&dbg.base);- In
Math.c:995:
Float a = FloatFromStr("1.5", &dbg.base); // exp -1
Float b = FloatFromStr("0.025", &dbg.base); // exp -3 -> scaling occurs
Float r = FloatInit(&dbg.base);- In
Math.c:996:
Float a = FloatFromStr("1.5", &dbg.base); // exp -1
Float b = FloatFromStr("0.025", &dbg.base); // exp -3 -> scaling occurs
Float r = FloatInit(&dbg.base);
bool ok = FloatAdd(&r, &a, &b);- In
Math.c:1019:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("2.5", &dbg.base);
Float b = FloatFromStr("3.5", &dbg.base);
Float r = FloatFromStr("123456789", &dbg.base); // pre-populated dest
- In
Math.c:1020:
Float a = FloatFromStr("2.5", &dbg.base);
Float b = FloatFromStr("3.5", &dbg.base);
Float r = FloatFromStr("123456789", &dbg.base); // pre-populated dest
- In
Math.c:1021:
Float a = FloatFromStr("2.5", &dbg.base);
Float b = FloatFromStr("3.5", &dbg.base);
Float r = FloatFromStr("123456789", &dbg.base); // pre-populated dest
bool ok = FloatAdd(&r, &a, &b);- In
Math.c:1042:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("7.25", &dbg.base);
Float b = FloatFromStr("-7.25", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1043:
Float a = FloatFromStr("7.25", &dbg.base);
Float b = FloatFromStr("-7.25", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1044:
Float a = FloatFromStr("7.25", &dbg.base);
Float b = FloatFromStr("-7.25", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatAdd(&r, &a, &b);- In
Math.c:1068:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float b = FloatFromStr("3", &dbg.base);
Float r = FloatFromStr("987654321", &dbg.base); // pre-populated dest
- In
Math.c:1069:
Float a = FloatFromStr("1", &dbg.base);
Float b = FloatFromStr("3", &dbg.base);
Float r = FloatFromStr("987654321", &dbg.base); // pre-populated dest
- In
Math.c:1070:
Float a = FloatFromStr("1", &dbg.base);
Float b = FloatFromStr("3", &dbg.base);
Float r = FloatFromStr("987654321", &dbg.base); // pre-populated dest
bool ok = FloatDiv(&r, &a, &b, 8u);- In
Math.c:1090:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFrom(0u, &dbg.base);
Float b = FloatFromStr("4", &dbg.base);
Float r = FloatFromStr("55555", &dbg.base); // pre-populated dest
- In
Math.c:1091:
Float a = FloatFrom(0u, &dbg.base);
Float b = FloatFromStr("4", &dbg.base);
Float r = FloatFromStr("55555", &dbg.base); // pre-populated dest
- In
Math.c:1092:
Float a = FloatFrom(0u, &dbg.base);
Float b = FloatFromStr("4", &dbg.base);
Float r = FloatFromStr("55555", &dbg.base); // pre-populated dest
bool ok = FloatDiv(&r, &a, &b, 4u);- In
Math.c:1114:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("2.5", &dbg.base);
Float b = FloatFromStr("4", &dbg.base);
Float r = FloatFromStr("314159265", &dbg.base); // pre-populated dest
- In
Math.c:1115:
Float a = FloatFromStr("2.5", &dbg.base);
Float b = FloatFromStr("4", &dbg.base);
Float r = FloatFromStr("314159265", &dbg.base); // pre-populated dest
- In
Math.c:1116:
Float a = FloatFromStr("2.5", &dbg.base);
Float b = FloatFromStr("4", &dbg.base);
Float r = FloatFromStr("314159265", &dbg.base); // pre-populated dest
bool ok = FloatMul(&r, &a, &b);- In
Math.c:1137:
bool test_add_int_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(2, &dbg.base);- In
Math.c:1138:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(2, &dbg.base);- In
Math.c:1154:
bool test_add_u64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1155:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatAdd(&r, &a, 2u);- In
Math.c:1169:
bool test_add_i64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1170:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatAdd(&r, &a, -2);- In
Math.c:1184:
bool test_add_f32_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1185:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatAdd(&r, &a, 0.5f);- In
Math.c:1199:
bool test_add_f64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1200:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatAdd(&r, &a, 0.25);- In
Math.c:1214:
bool test_sub_float_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float b = FloatFromStr("1.25", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1215:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float b = FloatFromStr("1.25", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1216:
Float a = FloatFromStr("5.5", &dbg.base);
Float b = FloatFromStr("1.25", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, &b);- In
Math.c:1231:
bool test_sub_int_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(2, &dbg.base);- In
Math.c:1232:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(2, &dbg.base);- In
Math.c:1248:
bool test_sub_u64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1249:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, 2u);- In
Math.c:1263:
bool test_sub_i64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1264:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, -2);- In
Math.c:1278:
bool test_sub_f32_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1279:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, 0.5f);- In
Math.c:1293:
bool test_sub_f64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1294:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("5.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, 0.25);- In
Math.c:1308:
bool test_mul_int_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(4, &dbg.base);- In
Math.c:1309:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(4, &dbg.base);- In
Math.c:1325:
bool test_mul_u64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1326:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatMul(&r, &a, 4u);- In
Math.c:1340:
bool test_mul_i64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1341:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatMul(&r, &a, -4);- In
Math.c:1355:
bool test_mul_f32_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1356:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatMul(&r, &a, 0.5f);- In
Math.c:1370:
bool test_mul_f64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1371:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1.5", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatMul(&r, &a, 0.25);- In
Math.c:1385:
bool test_div_int_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(4, &dbg.base);- In
Math.c:1386:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);
Int b = IntFrom(4, &dbg.base);- In
Math.c:1402:
bool test_div_u64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1403:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatDiv(&r, &a, 4u, 6u);- In
Math.c:1417:
bool test_div_i64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1418:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatDiv(&r, &a, -4, 6u);- In
Math.c:1432:
bool test_div_f32_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1433:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatDiv(&r, &a, 4.0f, 6u);- In
Math.c:1447:
bool test_div_f64_rhs_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);- In
Math.c:1448:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float a = FloatFromStr("1", &dbg.base);
Float r = FloatInit(&dbg.base);
bool ok = FloatDiv(&r, &a, 4.0, 6u);- In
Math.c:1460:
int main(void) {
WriteFmt("[INFO] Starting Float.Math tests\n\n");
TestFunction tests[] = {- In
Math.c:1534:
int total_deadend_tests = 0;
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Float.Math");
}- In
Convert.c:4:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>- In
Convert.c:53:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = float_from_u64(42, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);- In
Convert.c:70:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = float_from_i64(-42, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);- In
Convert.c:88:
Int integer = IntFromStr("12345678901234567890", ALLOCATOR_OF(&alloc));
Float value = float_from_int(&integer, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);- In
Convert.c:105:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc));- In
Convert.c:125:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("123.45", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));- In
Convert.c:142:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("-42", ALLOCATOR_OF(&alloc));
Int result_value = IntFrom(99, ALLOCATOR_OF(&alloc));- In
Convert.c:155:
bool test_float_string_round_trip(void) {
WriteFmt("Testing Float string round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:159:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("-123.45", ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);- In
Convert.c:183:
alloc.base.retry_limit = 5;
Float value = FloatFromStr("-123.45", ALLOCATOR_OF(&alloc));
ok = float_try_to_str(&text, &value, ALLOCATOR_OF(&alloc));- In
Convert.c:198:
bool test_float_very_large_string_round_trip(void) {
WriteFmt("Testing Float very large string round trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:202:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);- In
Convert.c:214:
bool test_float_scientific_parse(void) {
WriteFmt("Testing Float scientific parsing\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:218:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("1.2300e3", ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);- In
Convert.c:234:
DefaultAllocator alloc = DefaultAllocatorInit();
Float parsed = FloatFromStr("12.3.4", ALLOCATOR_OF(&alloc));
Float value = FloatInit(ALLOCATOR_OF(&alloc));
bool result = !FloatTryFromStr(&value, "12.3.4");- In
Convert.c:235:
Float parsed = FloatFromStr("12.3.4", ALLOCATOR_OF(&alloc));
Float value = FloatInit(ALLOCATOR_OF(&alloc));
bool result = !FloatTryFromStr(&value, "12.3.4");- In
Convert.c:262:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatInit(ALLOCATOR_OF(&alloc));
FloatTryFromStr(&value, (Zstr)NULL);
FloatDeinit(&value);- In
Convert.c:279:
DefaultAllocator alloc = DefaultAllocatorInit();
Float zero = FloatFromStr("0", &alloc.base);
Float neg = FloatFromStr("-7.5", &alloc.base);
Float product = FloatInit(&alloc.base);- In
Convert.c:280:
Float zero = FloatFromStr("0", &alloc.base);
Float neg = FloatFromStr("-7.5", &alloc.base);
Float product = FloatInit(&alloc.base);
Float canon = FloatFromStr("0", &alloc.base);- In
Convert.c:281:
Float zero = FloatFromStr("0", &alloc.base);
Float neg = FloatFromStr("-7.5", &alloc.base);
Float product = FloatInit(&alloc.base);
Float canon = FloatFromStr("0", &alloc.base);- In
Convert.c:282:
Float neg = FloatFromStr("-7.5", &alloc.base);
Float product = FloatInit(&alloc.base);
Float canon = FloatFromStr("0", &alloc.base);
bool ok = FloatMul(&product, &zero, &neg);- In
Convert.c:311:
Int whole = IntFrom(100, &alloc.base);
Float value = FloatFrom(&whole, &alloc.base);
// 100 == 1 * 10^2 after normalization.
- In
Convert.c:331:
Int whole = IntFrom(100, &alloc.base);
Float value = FloatFrom(&whole, &alloc.base);
Str text = FloatToStr(&value);- In
Convert.c:353:
Int whole = IntFrom(2000, &alloc.base);
Float value = FloatFrom(&whole, &alloc.base);
bool result = FloatExponent(&value) == 3;- In
Convert.c:377:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFrom((u64)100, &alloc.base);
bool ok = FloatExponent(&value) == 2;- In
Convert.c:389:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFrom((u64)100, &alloc.base);
Str text = FloatToStr(&value);
bool ok = ZstrCompare(StrBegin(&text), "100") == 0;- In
Convert.c:405:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFrom((i64)-200, &alloc.base);
bool ok = FloatExponent(&value) == 2;- In
Convert.c:420:
Str text = StrInitFromZstr("not-a-number", &alloc.base);
Float value = FloatInit(&alloc.base);
bool ok = (FloatTryFromStr(&value, &text) == false);- In
Convert.c:435:
Str text = StrInitFromZstr("3.14", &alloc.base);
Float value = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&value, &text);- In
Convert.c:459:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("3.14", &alloc.base);
Str text = FloatToStr(&value);- In
Convert.c:481:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("0.001", &alloc.base);
Str text = FloatToStr(&value);- In
Convert.c:500:
// 1e2 keeps significand 1 with exponent 2, exercising the >= 0 zero loop.
Float value = FloatFromStr("1e2", &alloc.base);
Str text = FloatToStr(&value);- In
Convert.c:515:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("3.14", &alloc.base);
Float b = FloatFromStr("3.14", &alloc.base);- In
Convert.c:516:
Float a = FloatFromStr("3.14", &alloc.base);
Float b = FloatFromStr("3.14", &alloc.base);
bool ok = float_hash(&a, 0) == float_hash(&b, 0);- In
Convert.c:536:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1", &alloc.base); // significand 1, exp 0
Float b = FloatFromStr("1e256", &alloc.base); // significand 1, exp 256
- In
Convert.c:537:
Float a = FloatFromStr("1", &alloc.base); // significand 1, exp 0
Float b = FloatFromStr("1e256", &alloc.base); // significand 1, exp 256
// Construction guards: same magnitude-1 significand, exponents differ only
- In
Convert.c:557:
DefaultAllocator alloc = DefaultAllocatorInit();
Float a = FloatFromStr("1", &alloc.base); // exp 0
Float b = FloatFromStr("1e1", &alloc.base); // exp 1
- In
Convert.c:558:
Float a = FloatFromStr("1", &alloc.base); // exp 0
Float b = FloatFromStr("1e1", &alloc.base); // exp 1
bool built_ok = (FloatExponent(&a) == 0) && (FloatExponent(&b) == 1);- In
Convert.c:577:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatInit(&alloc.base);
bool ok = (FloatTryFromStr(&value, ".") == false);- In
Convert.c:590:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatInit(&alloc.base);
bool ok = (FloatTryFromStr(&value, "+.") == false);- In
Convert.c:603:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&value, "1.");- In
Convert.c:627:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFrom(4503599627370496.0, &alloc.base); // 2^52, binexp == 0
Int whole = IntFromStr("4503599627370496", &alloc.base);- In
Convert.c:646:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFrom(4503599627370496.0, &alloc.base);
Str text = FloatToStr(&value);- In
Convert.c:668:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFrom(0.5, &dbg.base); // binexp < 0 -> 5^|binexp| path
FloatDeinit(&v);- In
Convert.c:679:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFrom(1.5f, &dbg.base); // binexp < 0 -> 5^|binexp| path
FloatDeinit(&v);- In
Convert.c:696:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFrom(1000u, &dbg.base); // 1000 -> significand 1, exp 3
FloatDeinit(&v);- In
Convert.c:713:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFromStr("1e3", &dbg.base); // exponent 3 > 0 -> pow10
Int r = IntInit(&dbg.base);- In
Convert.c:735:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFromStr("12e4", &dbg.base); // significand 12, exp 4
Int r = IntFrom(999999999u, &dbg.base); // pre-populated dest
- In
Convert.c:757:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFromStr("150e-1", &dbg.base); // 15.0, exact integer 15
Int r = IntFrom(777u, &dbg.base); // pre-populated dest
- In
Convert.c:783:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFromStr("1.5", &dbg.base); // significand 15, exponent -1
Int r = IntFrom(777u, &dbg.base); // pre-populated dest
- In
Convert.c:805:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFrom(0u, &dbg.base);
Int r = IntFrom(424242u, &dbg.base); // pre-populated dest
- In
Convert.c:826:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFromStr("12.5", &dbg.base);
Str out = StrInit(&dbg.base);- In
Convert.c:841:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFromStr("1200", &dbg.base); // exponent >= 0 arm
Str out = StrInit(&dbg.base);- In
Convert.c:863:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float v = FloatFromStr("99999", &dbg.base); // pre-populated target
bool ok = FloatTryFromStr(&v, "3.14159");- In
Convert.c:874:
int main(void) {
WriteFmt("[INFO] Starting Float.Convert tests\n\n");
TestFunction tests[] = {- In
Convert.c:930:
int total_deadend_tests = sizeof(deadend_tests) / sizeof(deadend_tests[0]);
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Float.Convert");
}- In
Access.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Log.h>- In
Access.c:16:
DefaultAllocator alloc = DefaultAllocatorInit();
Float zero = FloatInit(&alloc.base);
Float value = FloatFromStr("0.001", &alloc.base);- In
Access.c:17:
Float zero = FloatInit(&alloc.base);
Float value = FloatFromStr("0.001", &alloc.base);
bool result = FloatIsZero(&zero);- In
Access.c:33:
DefaultAllocator alloc = DefaultAllocatorInit();
Float neg = FloatFromStr("-42", &alloc.base);
Float pos = FloatFromStr("42", &alloc.base);
Float zero = FloatFromStr("-0.0", &alloc.base);- In
Access.c:34:
Float neg = FloatFromStr("-42", &alloc.base);
Float pos = FloatFromStr("42", &alloc.base);
Float zero = FloatFromStr("-0.0", &alloc.base);- In
Access.c:35:
Float neg = FloatFromStr("-42", &alloc.base);
Float pos = FloatFromStr("42", &alloc.base);
Float zero = FloatFromStr("-0.0", &alloc.base);
bool result = FloatIsNegative(&neg);- In
Access.c:53:
DefaultAllocator alloc = DefaultAllocatorInit();
Float value = FloatFromStr("12.34", &alloc.base);
bool result = FloatExponent(&value) == -2;- In
Access.c:63:
int main(void) {
WriteFmt("[INFO] Starting Float.Access tests\n\n");
TestFunction tests[] = {- In
Access.c:72:
int total_tests = sizeof(tests) / sizeof(tests[0]);
return run_test_suite(tests, total_tests, NULL, 0, "Float.Access");
}- In
Write.c:7:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Io.h>
#include <Misra/Std/Log.h>- In
Write.c:639:
bool test_float_formatting(void) {
WriteFmt("Testing Float formatting\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Write.c:646:
Str output = StrInit(&alloc);
bool success = true;
Float exact = FloatFromStr("1234567890.012345", alloc_base);
Float sci = FloatFromStr("12345.67", alloc_base);
Float short_v = FloatFromStr("1.2", alloc_base);- In
Write.c:647:
bool success = true;
Float exact = FloatFromStr("1234567890.012345", alloc_base);
Float sci = FloatFromStr("12345.67", alloc_base);
Float short_v = FloatFromStr("1.2", alloc_base);- In
Write.c:648:
Float exact = FloatFromStr("1234567890.012345", alloc_base);
Float sci = FloatFromStr("12345.67", alloc_base);
Float short_v = FloatFromStr("1.2", alloc_base);
StrAppendFmt(&output, "{}", exact);- In
Write.c:993:
DefaultAllocator alloc = DefaultAllocatorInit();
Float f = FloatInit(&alloc.base);
// Distinct sentinel so a no-op (failed) read is observable.
(void)FloatTryFromStr(&f, "99");- In
Write.c:1981:
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("1.0", alloc_base);
StrAppendFmt(&output, "{e}", v);- In
Write.c:2001:
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("0.0", alloc_base);
StrAppendFmt(&output, "{.0e}", v);- In
Write.c:2023:
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("0.0", alloc_base);
StrAppendFmt(&output, "{.3e}", v);- In
Write.c:2044:
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("12.0", alloc_base);
StrAppendFmt(&output, "{.2e}", v);- In
Write.c:2064:
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("12345.67", alloc_base);
StrAppendFmt(&output, "{e}", v);- In
Write.c:2379:
// pointer is left unmoved -- so a fully-consumed cursor distinguishes them.
bool test_m20_float_token_boundary(void) {
WriteFmt("m20: Float token boundary cursor\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Write.c:2385:
bool success = true;
Float val = FloatInit(alloc_base);
Zstr z = "3.5;";- In
Write.c:2409:
// value.
bool test_m20_float_token_boundary_no_trailer(void) {
WriteFmt("m20: Float token boundary, whole input\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Write.c:2415:
bool success = true;
Float val = FloatInit(alloc_base);
Zstr z = "12.25";- In
Write.c:2435:
// boundary and breaks the literal match.
bool test_m20_float_scientific_boundary(void) {
WriteFmt("m20: Float scientific token boundary\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Write.c:2441:
bool success = true;
Float val = FloatInit(alloc_base);
Zstr z = "1.5e2!";- In
Write.c:2461:
// expected value after a successful read.
bool test_m20_float_value_exact(void) {
WriteFmt("m20: Float value exact\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Write.c:2467:
bool success = true;
Float val = FloatInit(alloc_base);
Zstr z = "-0.25";- In
Write.c:2714:
bool success = true;
Float val = FloatFromStr("12", alloc_base);
Str out;- In
Write.c:2736:
bool success = true;
Float val = FloatFromStr("12", alloc_base);
Str out;- In
Write.c:2759:
bool success = true;
Float val = FloatFromStr("1.5", alloc_base);
Str out;- In
Write.c:2781:
bool success = true;
Float val = FloatFromStr("1.5", alloc_base);
Str out;- In
Write.c:2803:
bool success = true;
Float val = FloatFromStr("1.25", alloc_base);
Str out;- In
Write.c:2951:
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.0", &alloc.base);
StrAppendFmt(&out, "{e}", v);- In
Write.c:2971:
Str out = StrInit(&alloc);
Float v = FloatFromStr("0.001", &alloc.base);
StrAppendFmt(&out, "{e}", v);- In
Write.c:2990:
Str out = StrInit(&alloc);
Float v = FloatFromStr("1e12", &alloc.base);
StrAppendFmt(&out, "{e}", v);- In
Write.c:3633:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", alloc_base);
StrAppendFmt(&out, "{e}", v);- In
Write.c:3652:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", alloc_base);
StrAppendFmt(&out, "{.2e}", v);- In
Write.c:3677:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.2", alloc_base);
StrAppendFmt(&out, "XX");- In
Write.c:4000:
// "1.2" has 1 fractional digit; {.5} requests 5 -> 4 zeros are padded.
Float f = FloatFromStr("1.2", alloc_base);
StrAppendFmt(&out, "{.5}", f);
ok = ok && (ZstrCompare(StrBegin(&out), "1.20000") == 0);- In
Write.c:4005:
StrClear(&out);
Float g = FloatFromStr("3.14", alloc_base);
StrAppendFmt(&out, "{.6}", g);
ok = ok && (ZstrCompare(StrBegin(&out), "3.140000") == 0);- In
Write.c:5266:
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", ab);
StrAppendFmt(&out, "{e}", v);
bool ok = (ZstrCompare(StrBegin(&out), "1.234567e+04") == 0);- In
Write.c:5270:
bool ok = (ZstrCompare(StrBegin(&out), "1.234567e+04") == 0);
StrClear(&out);
Float w = FloatFromStr("0.001234", ab);
StrAppendFmt(&out, "{e}", w);
ok = ok && (ZstrCompare(StrBegin(&out), "1.234e-03") == 0);- In
Write.c:5290:
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.0", ab);
StrAppendFmt(&out, "{e}", v);
bool ok = (ZstrCompare(StrBegin(&out), "1e+00") == 0);- In
Write.c:5305:
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("2.0", ab);
StrAppendFmt(&out, "{e}", v);
bool ok = (ZstrCompare(StrBegin(&out), "2e+00") == 0);- In
Write.c:5319:
static bool test_float_decimal_no_leak(void) {
DBG_BEGIN(dbg, out);
Float v = FloatFromStr("1234567890.012345", &dbg.base);
StrAppendFmt(&out, "{}", v);
bool ok = (ZstrCompare(StrBegin(&out), "1234567890.012345") == 0);- In
Write.c:5331:
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("3.14159", ab);
StrAppendFmt(&out, "{.2}", v);
bool ok = (ZstrCompare(StrBegin(&out), "3.14") == 0);- In
Write.c:5350:
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("5", ab);
StrAppendFmt(&out, "{.3}", v);
bool ok = (ZstrCompare(StrBegin(&out), "5.000") == 0);- In
Write.c:5361:
static bool test_float_sci_no_leak(void) {
DBG_BEGIN(dbg, out);
Float v = FloatFromStr("12345.67", &dbg.base);
StrAppendFmt(&out, "{e}", v);
bool ok = (ZstrCompare(StrBegin(&out), "1.234567e+04") == 0);- In
Write.c:5374:
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.5", ab);
StrAppendFmt(&out, "{}", v);
bool ok = (ZstrCompare(StrBegin(&out), "1.5") == 0);- In
Write.c:5393:
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.5", ab);
StrAppendFmt(&out, "AB");
StrAppendFmt(&out, "{>6}", v);- In
Write.c:5492:
bool test_leak_write_float_default_freed(void) {
HeapAllocator fa = HeapAllocatorInit();
Float f = FloatFromStr("12345678901234567890123456789012345678901234567890.5", ALLOCATOR_OF(&fa));
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", f) && (StrLen(&out) > 0);- In
Write.c:5517:
// up in dbg's live count.
HeapAllocator fa = HeapAllocatorInit();
Float v = FloatFromStr("12345.67", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);- In
Write.c:5543:
HeapAllocator fa = HeapAllocatorInit();
Float v = FloatFromStr("0.0", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);- In
Write.c:5569:
HeapAllocator fa = HeapAllocatorInit();
Float v = FloatFromStr("3.14159", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);- In
Write.c:5596:
HeapAllocator fa = HeapAllocatorInit();
Float v = FloatFromStr("42", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);- In
Write.c:5702:
bool test_leak_write_float_freed(void) {
HeapAllocator va = HeapAllocatorInit();
Float v = FloatFromStr("2.718281828", ALLOCATOR_OF(&va));
LEAK_WRITE_PRELUDE();
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);- In
Read.c:7:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Io.h>- In
Read.c:959:
bool test_float_reading(void) {
WriteFmt("Testing Float reading\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Read.c:967:
bool success = true;
Float dec = FloatInit(alloc_base);
Float sci = FloatInit(alloc_base);
Float neg = FloatInit(alloc_base);- In
Read.c:968:
Float dec = FloatInit(alloc_base);
Float sci = FloatInit(alloc_base);
Float neg = FloatInit(alloc_base);- In
Read.c:969:
Float dec = FloatInit(alloc_base);
Float sci = FloatInit(alloc_base);
Float neg = FloatInit(alloc_base);
Str dec_text = StrInit(&alloc);- In
Read.c:2114:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Float f = FloatInit(ab);
(void)FloatTryFromStr(&f, "99"); // sentinel
StrReadFmt(in, "{}", f);- In
Read.c:2632:
static bool test_read_float_value(void) {
DebugAllocator dbg = DebugAllocatorInit();
Float f = FloatInit(&dbg.base);
Zstr z = "3.14159";
StrReadFmt(z, "{}", f);- In
Read.c:2648:
static bool test_read_float_reject_no_leak(void) {
DebugAllocator dbg = DebugAllocatorInit();
Float f = FloatInit(&dbg.base);
(void)FloatTryFromStr(&f, "42");
Zstr z = "xyz"; // no float token
- In
Read.c:2651:
(void)FloatTryFromStr(&f, "42");
Zstr z = "xyz"; // no float token
Zstr out = str_read_fmt(z, "{}", (TypeSpecificIO[]) {TO_TYPE_SPECIFIC_IO(Float, &f)}, 1);
Str t = FloatToStr(&f);
bool ok = (out == NULL) && (ZstrCompare(StrBegin(&t), "42") == 0);- In
Read.c:2791:
bool test_leak_read_float_exp_overflow_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float fv = FloatInit(ALLOCATOR_OF(&dbg));
Zstr p = "1e99999999999999999999999999999999999999999999999999";
StrReadFmt(p, "{}", fv);- In
Read.c:2848:
// Seed with a heap-backed Float (wide significand) so the old significand
// storage is visible in dbg's live count before the reassignment.
Float value = FloatFromStr("987654321098765432109876543210.5", adbg);
Zstr input = "2.5";
Last updated on