LibreOffice Module tools (master) 1
Functions
fract.cxx File Reference
#include <tools/fract.hxx>
#include <tools/debug.hxx>
#include <o3tl/hash_combine.hxx>
#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <boost/rational.hpp>
Include dependency graph for fract.cxx:

Go to the source code of this file.

Functions

static boost::rational< sal_Int32 > rational_FromDouble (double dVal)
 
static void rational_ReduceInaccurate (boost::rational< sal_Int32 > &rRational, unsigned nSignificantBits)
 
static int impl_NumberOfBits (sal_uInt32 nNum)
 Find the number of bits required to represent this number, using the CLZ intrinsic. More...
 
static boost::rational< sal_Int32 > toRational (sal_Int32 n, sal_Int32 d)
 
static constexpr bool isOutOfRange (sal_Int64 nNum)
 
Fraction operator+ (const Fraction &rVal1, const Fraction &rVal2)
 
Fraction operator- (const Fraction &rVal1, const Fraction &rVal2)
 
Fraction operator* (const Fraction &rVal1, const Fraction &rVal2)
 
Fraction operator/ (const Fraction &rVal1, const Fraction &rVal2)
 
bool operator!= (const Fraction &rVal1, const Fraction &rVal2)
 
bool operator<= (const Fraction &rVal1, const Fraction &rVal2)
 
bool operator>= (const Fraction &rVal1, const Fraction &rVal2)
 
bool operator== (const Fraction &rVal1, const Fraction &rVal2)
 
bool operator< (const Fraction &rVal1, const Fraction &rVal2)
 
bool operator> (const Fraction &rVal1, const Fraction &rVal2)
 

Function Documentation

◆ impl_NumberOfBits()

static int impl_NumberOfBits ( sal_uInt32  nNum)
static

Find the number of bits required to represent this number, using the CLZ intrinsic.

Definition at line 412 of file fract.cxx.

Referenced by rational_ReduceInaccurate().

◆ isOutOfRange()

static constexpr bool isOutOfRange ( sal_Int64  nNum)
staticconstexpr

Definition at line 52 of file fract.cxx.

Referenced by Fraction::Fraction().

◆ operator!=()

bool operator!= ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 340 of file fract.cxx.

References SAL_WARN.

◆ operator*()

Fraction operator* ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 326 of file fract.cxx.

◆ operator+()

Fraction operator+ ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 312 of file fract.cxx.

References SAL_WARN.

◆ operator-()

Fraction operator- ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 319 of file fract.cxx.

◆ operator/()

Fraction operator/ ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 333 of file fract.cxx.

◆ operator<()

bool operator< ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 366 of file fract.cxx.

◆ operator<=()

bool operator<= ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 345 of file fract.cxx.

◆ operator==()

bool operator== ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 355 of file fract.cxx.

◆ operator>()

bool operator> ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 377 of file fract.cxx.

◆ operator>=()

bool operator>= ( const Fraction rVal1,
const Fraction rVal2 
)

Definition at line 350 of file fract.cxx.

◆ rational_FromDouble()

static boost::rational< sal_Int32 > rational_FromDouble ( double  dVal)
static

Definition at line 393 of file fract.cxx.

References abs().

Referenced by Fraction::Fraction().

◆ rational_ReduceInaccurate()

static void rational_ReduceInaccurate ( boost::rational< sal_Int32 > &  rRational,
unsigned  nSignificantBits 
)
static

Definition at line 443 of file fract.cxx.

References DBG_ASSERT, and impl_NumberOfBits().

Referenced by Fraction::ReduceInaccurate().

◆ toRational()

static boost::rational< sal_Int32 > toRational ( sal_Int32  n,
sal_Int32  d 
)
static