| 1 | /* ExtendedReal_def.h |
| 2 | * |
| 3 | * Copyright (C) 2025 David Weenink |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | /* |
| 20 | An ExtendedReal has two parts (real,extension) |
| 21 | The number in the extension part represents: power (epsilon, power (2, extension)), |
| 22 | where epsilon is a number larger than zero but smaller than any real number r. |
| 23 | r.epsilon < expsilon^2. |
| 24 | */ |
| 25 | |
| 26 | #define ooSTRUCTcxx . . $ `dwsys/ExtendedReal_def.h:26:9`! ExtendedReal |
| 27 | oo_DEFINE_STRUCTcxx . . $ `sys/oo.h:159:9`! (ExtendedReal) |
| 28 | |
| 29 | oo_DOUBLEcxx . . $ `sys/oo.h:58:9`! (real) |
| 30 | oo_INTEGERcxx . . $ `sys/oo.h:45:9`! (extension) |
| 31 | |
| 32 | #if oo_DECLARINGcxx . . $ `sys/oo.h:230:9`! |
| 33 | |
| 34 | constexpr void operatorcxx . . $ structExtendedReal#`operator+=`(b48bb13321a91ed8).+= (const structExtendedRealcxx . . $ structExtendedReal#& other) { |
| 35 | realcxx . . $ structExtendedReal#real. += other.realcxx . . $ structExtendedReal#real.; |
| 36 | extensioncxx . . $ structExtendedReal#extension. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (extensioncxx . . $ structExtendedReal#extension., other.extensioncxx . . $ structExtendedReal#extension.); |
| 37 | } |
| 38 | |
| 39 | constexpr void operatorcxx . . $ structExtendedReal#`operator-=`(b48bb13321a91ed8).-= (const structExtendedRealcxx . . $ structExtendedReal#& other) { |
| 40 | this -> realcxx . . $ structExtendedReal#real. -= other.realcxx . . $ structExtendedReal#real.; |
| 41 | this -> extensioncxx . . $ structExtendedReal#extension. = this -> extensioncxx . . $ structExtendedReal#extension. <= other.extensioncxx . . $ structExtendedReal#extension. ? this -> extensioncxx . . $ structExtendedReal#extension. : - other.extensioncxx . . $ structExtendedReal#extension.; |
| 42 | } |
| 43 | |
| 44 | friend inline bool operatorcxx . . $ `operator<`(4e89fa3d84222075).< (const structExtendedRealcxx . . $ structExtendedReal#& lhs, const structExtendedRealcxx . . $ structExtendedReal#& rhs) { |
| 45 | return stdcxx . . $ std/::tiecxx . . $ std/tie(988772b69a7ca893). (lhs.realcxx . . $ structExtendedReal#real., rhs.extensioncxx . . $ structExtendedReal#extension.) <cxx . . $ std/`operator<`(48af00471b8240b). stdcxx . . $ std/::tiecxx . . $ std/tie(988772b69a7ca893). (rhs.realcxx . . $ structExtendedReal#real., lhs.extensioncxx . . $ structExtendedReal#extension.); |
| 46 | } |
| 47 | |
| 48 | friend inline bool operatorcxx . . $ `operator>`(4e89fa3d84222075).> (const structExtendedRealcxx . . $ structExtendedReal#& lhs, const structExtendedRealcxx . . $ structExtendedReal#& rhs) { |
| 49 | return rhs <cxx . . $ `operator<`(4e89fa3d84222075). lhs; |
| 50 | } |
| 51 | friend inline bool operatorcxx . . $ `operator<=`(4e89fa3d84222075).<= (const structExtendedRealcxx . . $ structExtendedReal#& lhs, const structExtendedRealcxx . . $ structExtendedReal#& rhs) { |
| 52 | return ! (lhs >cxx . . $ `operator>`(4e89fa3d84222075). rhs); |
| 53 | } |
| 54 | friend inline bool operatorcxx . . $ `operator>=`(4e89fa3d84222075).>= (const structExtendedRealcxx . . $ structExtendedReal#& lhs, const structExtendedRealcxx . . $ structExtendedReal#& rhs) { |
| 55 | return ! (lhs <cxx . . $ `operator<`(4e89fa3d84222075). rhs); |
| 56 | } |
| 57 | friend inline bool operatorcxx . . $ `operator==`(4e89fa3d84222075).== (const structExtendedRealcxx . . $ structExtendedReal#& lhs, const structExtendedRealcxx . . $ structExtendedReal#& rhs) { |
| 58 | return stdcxx . . $ std/::tiecxx . . $ std/tie(988772b69a7ca893). (lhs.realcxx . . $ structExtendedReal#real., lhs.extensioncxx . . $ structExtendedReal#extension.) ==cxx . . $ std/`operator==`(48af00471b8240b). stdcxx . . $ std/::tiecxx . . $ std/tie(988772b69a7ca893). (rhs.realcxx . . $ structExtendedReal#real., rhs.extensioncxx . . $ structExtendedReal#extension.); |
| 59 | } |
| 60 | friend inline bool operatorcxx . . $ `operator!=`(4e89fa3d84222075).!= (const structExtendedRealcxx . . $ structExtendedReal#& lhs, const structExtendedRealcxx . . $ structExtendedReal#& rhs) { |
| 61 | return ! (lhs ==cxx . . $ `operator==`(4e89fa3d84222075). rhs); |
| 62 | } |
| 63 | #endif |
| 64 | |
| 65 | oo_END_STRUCTcxx . . $ `sys/oo.h:163:9`! (ExtendedReal) |
| 66 | #undef ooSTRUCTcxx . . $ `dwsys/ExtendedReal_def.h:26:9`! |
| 67 | |
| 68 | /* End of file ExtendedReal_def.h */ |