Last change
on this file since 976 was
976,
checked in by sam, 11 years ago
|
core: allow to cast reals to doubles in addition to floats.
|
File size:
1.2 KB
|
Line | |
---|
1 | // |
---|
2 | // Lol Engine |
---|
3 | // |
---|
4 | // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> |
---|
5 | // This program is free software; you can redistribute it and/or |
---|
6 | // modify it under the terms of the Do What The Fuck You Want To |
---|
7 | // Public License, Version 2, as published by Sam Hocevar. See |
---|
8 | // http://sam.zoy.org/projects/COPYING.WTFPL for more details. |
---|
9 | // |
---|
10 | |
---|
11 | // |
---|
12 | // The Real class |
---|
13 | // -------------- |
---|
14 | // |
---|
15 | |
---|
16 | #if !defined __LOL_REAL_H__ |
---|
17 | #define __LOL_REAL_H__ |
---|
18 | |
---|
19 | #include <stdint.h> |
---|
20 | |
---|
21 | namespace lol |
---|
22 | { |
---|
23 | |
---|
24 | class real |
---|
25 | { |
---|
26 | static int const BIGITS = 32; |
---|
27 | |
---|
28 | public: |
---|
29 | inline real() { } |
---|
30 | real(float f); |
---|
31 | real(double f); |
---|
32 | |
---|
33 | operator float() const; |
---|
34 | operator double() const; |
---|
35 | |
---|
36 | real operator -() const; |
---|
37 | real operator +(real const &x) const; |
---|
38 | real operator -(real const &x) const; |
---|
39 | real operator *(real const &x) const; |
---|
40 | real operator /(real const &x) const; |
---|
41 | |
---|
42 | bool operator <(real const &x) const; |
---|
43 | bool operator >(real const &x) const; |
---|
44 | bool operator <=(real const &x) const; |
---|
45 | bool operator >=(real const &x) const; |
---|
46 | |
---|
47 | friend real fres(real const &x); |
---|
48 | |
---|
49 | void print() const; |
---|
50 | |
---|
51 | private: |
---|
52 | uint32_t m_size; |
---|
53 | uint32_t m_signexp; |
---|
54 | uint16_t m_mantissa[BIGITS]; |
---|
55 | }; |
---|
56 | |
---|
57 | } /* namespace lol */ |
---|
58 | |
---|
59 | #endif // __LOL_REAL_H__ |
---|
60 | |
---|
Note: See
TracBrowser
for help on using the repository browser.