Quellcode durchsuchen

math: allow to build real numbers from 64-bit integers.

undefined
Sam Hocevar vor 10 Jahren
Ursprung
Commit
efe8e1d051
2 geänderte Dateien mit 14 neuen und 6 gelöschten Zeilen
  1. +8
    -4
      src/lol/math/real.h
  2. +6
    -2
      src/math/real.cpp

+ 8
- 4
src/lol/math/real.h Datei anzeigen

@@ -43,8 +43,10 @@ public:


Real(float f); Real(float f);
Real(double f); Real(double f);
Real(int i); Real(int32_t i);
Real(unsigned int i); Real(uint32_t i);
Real(int64_t i);
Real(uint64_t i);


Real(char const *str); Real(char const *str);


@@ -212,8 +214,10 @@ template<> real const &real::operator =(real const &x);
template<> real::~Real(); template<> real::~Real();
template<> real::Real(float f); template<> real::Real(float f);
template<> real::Real(double f); template<> real::Real(double f);
template<> real::Real(int i); template<> real::Real(int32_t i);
template<> real::Real(unsigned int i); template<> real::Real(uint32_t i);
template<> real::Real(int64_t i);
template<> real::Real(uint64_t i);
template<> real::Real(char const *str); template<> real::Real(char const *str);


template<> real::operator float() const; template<> real::operator float() const;


+ 6
- 2
src/math/real.cpp Datei anzeigen

@@ -98,9 +98,13 @@ template<> real::~Real()
delete[] m_mantissa; delete[] m_mantissa;
} }


/* FIXME: 64-bit integer loading is incorrect,we lose precision. */
template<> real::Real(int32_t i) { new(this) real((double)i); }
template<> real::Real(uint32_t i) { new(this) real((double)i); }
template<> real::Real(int64_t i) { new(this) real((double)i); }
template<> real::Real(uint64_t i) { new(this) real((double)i); }

template<> real::Real(float f) { new(this) real((double)f); } template<> real::Real(float f) { new(this) real((double)f); }
template<> real::Real(int i) { new(this) real((double)i); }
template<> real::Real(unsigned int i) { new(this) real((double)i); }


template<> real::Real(double d) template<> real::Real(double d)
{ {


||||||
x
 
000:0
Laden…
Abbrechen
Speichern