BASIS 2 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Friends | List of all members
alicat_basis2::Decimal Struct Reference

An exact decimal number as the instrument printed it: +0021513.0 is {215130, 1}. More...

#include <alicat_basis2_types.hpp>

Public Member Functions

constexpr double ToDouble () const noexcept
 
constexpr int64_t ToMilli () const noexcept
 

Public Attributes

int64_t mantissa {0}
 The number without its decimal point.
 
uint8_t decimals {0}
 Digits after the point.
 

Friends

constexpr bool operator== (const Decimal &, const Decimal &)=default
 Equal mantissa and equal decimal count (hidden friend, MISRA C++:2023 Rule 16.6.1).
 

Detailed Description

An exact decimal number as the instrument printed it: +0021513.0 is {215130, 1}.

mantissa stays below 10^15 and decimals below 7 for everything the driver parses.

Member Function Documentation

◆ ToDouble()

constexpr double alicat_basis2::Decimal::ToDouble ( ) const
inlineconstexprnoexcept
Returns
The value as a double (division by a power of ten; exact for the digits the instrument prints).

◆ ToMilli()

constexpr int64_t alicat_basis2::Decimal::ToMilli ( ) const
inlineconstexprnoexcept
Returns
The value in thousandths, rounded half away from zero.

The documentation for this struct was generated from the following file: