/usr/include/ETL/_fixed.h is in etl-dev 1.2.1-0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | /*! ========================================================================
** Extended Template and Library
** Fixed-Point Math Class Implementation
** $Id$
**
** Copyright (c) 2002 Robert B. Quattlebaum Jr.
** Copyright (c) 2007 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
** published by the Free Software Foundation; either version 2 of
** the License, or (at your option) any later version.
**
** This package is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
**
** === N O T E S ===========================================================
**
** This is an internal header file, included by other ETL headers.
** You should not attempt to use it directly.
**
** ========================================================================= */
/* === S T A R T =========================================================== */
#ifndef __ETL__FIXED_H
#define __ETL__FIXED_H
/* === H E A D E R S ======================================================= */
#include <cmath>
/* === M A C R O S ========================================================= */
// the "+0.5" code was commented out - maybe to make thing run faster?
// it can be re-enabled by uncommenting this next line:
// #define ROUND_TO_NEAREST_INTEGER
#ifndef ETL_FIXED_TYPE
# define ETL_FIXED_TYPE int
#endif
#ifndef ETL_FIXED_BITS
#define ETL_FIXED_BITS 12
#endif
#ifndef ETL_FIXED_EPSILON
#define ETL_FIXED_EPSILON _EPSILON()
#endif
#ifdef __GNUC___
#define ETL_ATTRIB_CONST __attribute__ ((const))
#define ETL_ATTRIB_PURE __attribute__ ((pure))
#define ETL_ATTRIB_INLINE __attribute__ ((always_inline))
#else
#define ETL_ATTRIB_CONST
#define ETL_ATTRIB_PURE
#define ETL_ATTRIB_INLINE
#endif
/* === C L A S S E S & S T R U C T S ======================================= */
_ETL_BEGIN_NAMESPACE
// Forward declarations
template<typename T, unsigned int FIXED_BITS> class fixed_base;
//template<> class fixed_base<char>;
_ETL_END_NAMESPACE
_STD_BEGIN_NAMESPACE
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> abs(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> cos(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> cosh(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> exp(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> log(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> log10(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> pow(const _ETL::fixed_base<T,FIXED_BITS>&, int);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> pow(const _ETL::fixed_base<T,FIXED_BITS>&, const T&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> pow(const _ETL::fixed_base<T,FIXED_BITS>&,
const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> pow(const _ETL::fixed_base<T,FIXED_BITS>&, const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> sin(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> sinh(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> sqrt(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> tan(const _ETL::fixed_base<T,FIXED_BITS>&);
template<typename T, unsigned int FIXED_BITS> _ETL::fixed_base<T,FIXED_BITS> tanh(const _ETL::fixed_base<T,FIXED_BITS>&);
_STD_END_NAMESPACE
_ETL_BEGIN_NAMESPACE
/*! ========================================================================
** \class fixed_base
** \brief Fixed-point template base class
**
** A more detailed description needs to be written.
*/
template <class T,unsigned int FIXED_BITS>
class fixed_base
{
public:
typedef T value_type;
private:
T _data;
typedef fixed_base<T,FIXED_BITS> _fixed;
typedef fixed_base<T,FIXED_BITS> self_type;
inline static bool _TYPE_SMALLER_THAN_INT() ETL_ATTRIB_CONST ETL_ATTRIB_INLINE;
inline static bool _USING_ALL_BITS() ETL_ATTRIB_CONST ETL_ATTRIB_INLINE;
inline static value_type _ONE() ETL_ATTRIB_CONST ETL_ATTRIB_INLINE;
inline static value_type _F_MASK() ETL_ATTRIB_CONST ETL_ATTRIB_INLINE;
inline static float _EPSILON() ETL_ATTRIB_CONST ETL_ATTRIB_INLINE;
class raw { };
public:
fixed_base()ETL_ATTRIB_INLINE;
fixed_base(const float &f)ETL_ATTRIB_INLINE;
fixed_base(const double &f)ETL_ATTRIB_INLINE;
fixed_base(const long double &f)ETL_ATTRIB_INLINE;
fixed_base(const int &i)ETL_ATTRIB_INLINE;
fixed_base(const int &n,const int &d)ETL_ATTRIB_INLINE; //!< Fraction constructor
fixed_base(const _fixed &x)ETL_ATTRIB_INLINE;
fixed_base(value_type x,raw)ETL_ATTRIB_INLINE;
T &data() ETL_ATTRIB_PURE ETL_ATTRIB_INLINE;
const T &data()const ETL_ATTRIB_PURE ETL_ATTRIB_INLINE;
const _fixed& operator+=(const _fixed &rhs) ETL_ATTRIB_INLINE;
const _fixed& operator-=(const _fixed &rhs) ETL_ATTRIB_INLINE;
template<typename U> const _fixed& operator*=(const U &rhs) ETL_ATTRIB_INLINE;
template<typename U> const _fixed& operator/=(const U &rhs) ETL_ATTRIB_INLINE;
const _fixed& operator*=(const _fixed &rhs) ETL_ATTRIB_INLINE;
const _fixed& operator/=(const _fixed &rhs) ETL_ATTRIB_INLINE;
const _fixed& operator*=(const int &rhs) ETL_ATTRIB_INLINE;
const _fixed& operator/=(const int &rhs) ETL_ATTRIB_INLINE;
template<typename U> _fixed operator+(const U &rhs)const ETL_ATTRIB_INLINE;
template<typename U> _fixed operator-(const U &rhs)const ETL_ATTRIB_INLINE;
template<typename U> _fixed operator*(const U &rhs)const ETL_ATTRIB_INLINE;
template<typename U> _fixed operator/(const U &rhs)const ETL_ATTRIB_INLINE;
_fixed operator+(const _fixed &rhs)const ETL_ATTRIB_INLINE;
_fixed operator-(const _fixed &rhs)const ETL_ATTRIB_INLINE;
_fixed operator*(const _fixed &rhs)const ETL_ATTRIB_INLINE;
_fixed operator/(const _fixed &rhs)const ETL_ATTRIB_INLINE;
_fixed operator*(const int &rhs)const ETL_ATTRIB_INLINE;
_fixed operator/(const int &rhs)const ETL_ATTRIB_INLINE;
_fixed operator*(const float &rhs)const ETL_ATTRIB_INLINE;
_fixed operator*(const double &rhs)const ETL_ATTRIB_INLINE;
// Negation Operator
_fixed operator-()const ETL_ATTRIB_INLINE;
// Casting Operators
inline operator float()const ETL_ATTRIB_INLINE;
inline operator double()const ETL_ATTRIB_INLINE;
inline operator long double()const ETL_ATTRIB_INLINE;
inline operator int()const ETL_ATTRIB_INLINE;
inline operator bool()const ETL_ATTRIB_INLINE;
_fixed floor()const;
_fixed ceil()const;
_fixed round()const;
bool operator==(const _fixed &rhs)const { return data()==rhs.data(); }
bool operator!=(const _fixed &rhs)const { return data()!=rhs.data(); }
bool operator<(const _fixed &rhs)const { return data()<rhs.data(); }
bool operator>(const _fixed &rhs)const { return data()>rhs.data(); }
bool operator<=(const _fixed &rhs)const { return data()<=rhs.data(); }
bool operator>=(const _fixed &rhs)const { return data()>=rhs.data(); }
};
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::fixed_base()
{}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::fixed_base(const _fixed &x):_data(x._data)
{}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::fixed_base(const float &f):_data(static_cast<value_type>(f*_ONE()
#ifdef ROUND_TO_NEAREST_INTEGER
+0.5f
#endif
)) {}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::fixed_base(const double &f):_data(static_cast<value_type>(f*_ONE()
#ifdef ROUND_TO_NEAREST_INTEGER
+0.5
#endif
)) {}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::fixed_base(const long double &f):_data(static_cast<value_type>(f*_ONE()
#ifdef ROUND_TO_NEAREST_INTEGER
+0.5
#endif
)) {}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::fixed_base(const int &i):_data(i<<FIXED_BITS)
{}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::fixed_base(value_type x,raw):_data(x) { }
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::fixed_base(const int &n,const int &d):_data((n<<FIXED_BITS)/d) { }
template <class T,unsigned int FIXED_BITS> inline bool
fixed_base<T,FIXED_BITS>::_TYPE_SMALLER_THAN_INT()
{
return sizeof(T)<sizeof(int);
}
template <class T,unsigned int FIXED_BITS> inline bool
fixed_base<T,FIXED_BITS>::_USING_ALL_BITS()
{
return sizeof(T)*8==FIXED_BITS;
}
template <class T,unsigned int FIXED_BITS> inline T
fixed_base<T,FIXED_BITS>::_ONE()
{
return static_cast<T>((_USING_ALL_BITS()?~T(0):1<<FIXED_BITS));
}
template <class T,unsigned int FIXED_BITS> inline T
fixed_base<T,FIXED_BITS>::_F_MASK()
{
return static_cast<T>(_USING_ALL_BITS()?~T(0):_ONE()-1);
}
template <class T,unsigned int FIXED_BITS> inline float
fixed_base<T,FIXED_BITS>::_EPSILON()
{
return 1.0f/((float)_ONE()*2);
}
template <class T,unsigned int FIXED_BITS>T &
fixed_base<T,FIXED_BITS>::data()
{
return _data;
}
template <class T,unsigned int FIXED_BITS>const T &
fixed_base<T,FIXED_BITS>::data()const
{
return _data;
}
//! fixed+=fixed
template <class T,unsigned int FIXED_BITS>const fixed_base<T,FIXED_BITS> &
fixed_base<T,FIXED_BITS>::operator+=(const _fixed &rhs)
{
_data+=rhs._data;
return *this;
}
//! fixed-=fixed
template <class T,unsigned int FIXED_BITS>const fixed_base<T,FIXED_BITS> &
fixed_base<T,FIXED_BITS>::operator-=(const _fixed &rhs)
{
_data-=rhs._data;
return *this;
}
//! fixed*=fixed
template <class T,unsigned int FIXED_BITS>const fixed_base<T,FIXED_BITS> &
fixed_base<T,FIXED_BITS>::operator*=(const _fixed &rhs)
{
if(_TYPE_SMALLER_THAN_INT())
_data=static_cast<T>((int)_data*(int)rhs._data>>FIXED_BITS);
else
{
_data*=rhs._data;
_data>>=FIXED_BITS;
}
return *this;
}
//! fixed/=fixed
template <class T,unsigned int FIXED_BITS>const fixed_base<T,FIXED_BITS> &
fixed_base<T,FIXED_BITS>::operator/=(const _fixed &rhs)
{
if(_TYPE_SMALLER_THAN_INT())
_data=static_cast<T>((int)_data/(int)rhs._data<<FIXED_BITS);
else
{
_data/=rhs._data;
_data<<=FIXED_BITS;
}
return *this;
}
template <class T,unsigned int FIXED_BITS> template<typename U> const fixed_base<T,FIXED_BITS> &
fixed_base<T,FIXED_BITS>::operator*=(const U &rhs)
{
return operator*=(fixed_base<T,FIXED_BITS>(rhs));
}
template <class T,unsigned int FIXED_BITS> template<typename U> const fixed_base<T,FIXED_BITS> &
fixed_base<T,FIXED_BITS>::operator/=(const U &rhs)
{
return operator/=(fixed_base<T,FIXED_BITS>(rhs));
}
//! fixed*=int
template <class T,unsigned int FIXED_BITS>const fixed_base<T,FIXED_BITS> &
fixed_base<T,FIXED_BITS>::operator*=(const int &rhs)
{
_data*=rhs; return *this;
}
//! fixed/=int
template <class T,unsigned int FIXED_BITS>const fixed_base<T,FIXED_BITS> &
fixed_base<T,FIXED_BITS>::operator/=(const int &rhs)
{
_data/=rhs; return *this;
}
//! fixed + fixed
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator+(const _fixed &rhs)const
{
_fixed ret;
ret._data=_data+rhs._data;
return ret;
}
//! fixed - fixed
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator-(const _fixed &rhs)const
{
_fixed ret;
ret._data=_data-rhs._data;
return ret;
}
//! fixed * fixed
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator*(const _fixed &rhs)const
{
_fixed ret;
ret._data=((_data*rhs._data)>>FIXED_BITS);
return ret;
//return reinterpret_cast<_fixed>((_data*rhs._data)>>FIXED_BITS);
}
//! fixed / fixed
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator/(const _fixed &rhs)const
{
_fixed ret;
ret._data=((_data/rhs._data)<<FIXED_BITS);
return ret;
//return reinterpret_cast<_fixed>((_data/rhs._data)<<FIXED_BITS);
}
//! fixed + ...
template <class T,unsigned int FIXED_BITS> template<typename U> fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator+(const U &rhs) const
{
return operator+(fixed_base<T,FIXED_BITS>(rhs));
}
//! fixed - ...
template <class T,unsigned int FIXED_BITS> template<typename U> fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator-(const U &rhs) const
{
return operator-(fixed_base<T,FIXED_BITS>(rhs));
}
//! fixed * ...
template <class T,unsigned int FIXED_BITS> template<typename U> fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator*(const U &rhs) const
{
return operator*(fixed_base<T,FIXED_BITS>(rhs));
}
//! fixed / ...
template <class T,unsigned int FIXED_BITS> template<typename U> fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator/(const U &rhs) const
{
return operator/(fixed_base<T,FIXED_BITS>(rhs));
}
//! fixed * int
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator*(const int &rhs)const
{
_fixed ret;
ret._data=_data*rhs;
return ret;
//return reinterpret_cast<_fixed>(_data*rhs);
}
//! fixed * float
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator*(const float &rhs)const
{
return (*this)*_fixed(rhs);
}
//! fixed * double
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator*(const double &rhs)const
{
return (*this)*_fixed(rhs);
}
//! fixed / int
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator/(const int &rhs)const
{
_fixed ret;
ret._data=_data/rhs;
return ret;
//return reinterpret_cast<_fixed>(_data/rhs);
}
//! float * fixed
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
operator*(const float& lhs, const fixed_base<T,FIXED_BITS> &rhs)
{
return rhs*lhs;
}
//! double * fixed
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
operator*(const double& lhs, const fixed_base<T,FIXED_BITS> &rhs)
{
return rhs*lhs;
}
// Negation Operator
template <class T,unsigned int FIXED_BITS>fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator-()const
{
_fixed ret; ret._data=-_data; return ret;
}
// Casting Operators
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator float()const
{
return static_cast<float>(_data)/static_cast<float>(_ONE());
}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator double()const
{
return static_cast<double>(_data)/static_cast<double>(_ONE());
}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator long double()const
{
return static_cast<long double>(_data)/static_cast<long double>(_ONE());
}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator int()const
{
return static_cast<int>(_data>>FIXED_BITS);
}
template <class T,unsigned int FIXED_BITS>
fixed_base<T,FIXED_BITS>::operator bool()const
{
return static_cast<bool>(_data);
}
template <class T,unsigned int FIXED_BITS> fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::floor()const
{
_fixed ret(*this);
ret._data&=~_F_MASK();
return ret;
}
template <class T,unsigned int FIXED_BITS> fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::ceil()const
{
_fixed ret(*this);
if(ret._data&_F_MASK())
ret._data=(ret._data&~_F_MASK()) + _ONE();
else
ret._data&=~_F_MASK();
return ret;
}
template <class T,unsigned int FIXED_BITS> fixed_base<T,FIXED_BITS>
fixed_base<T,FIXED_BITS>::round()const
{
_fixed ret(*this);
ret._data+=_ONE()>>1;
ret._data&=~_F_MASK();
return ret;
}
typedef fixed_base<ETL_FIXED_TYPE,ETL_FIXED_BITS> fixed;
_ETL_END_NAMESPACE
_STD_BEGIN_NAMESPACE
template <class T,unsigned int FIXED_BITS>
inline _ETL::fixed_base<T,FIXED_BITS>
ceil(const _ETL::fixed_base<T,FIXED_BITS> &rhs)
{ return rhs.ceil(); }
template <class T,unsigned int FIXED_BITS>
_ETL::fixed_base<T,FIXED_BITS>
floor(const _ETL::fixed_base<T,FIXED_BITS> &rhs)
{ return rhs.floor(); }
template <class T,unsigned int FIXED_BITS>
_ETL::fixed_base<T,FIXED_BITS>
round(const _ETL::fixed_base<T,FIXED_BITS> &rhs)
{ return rhs.round(); }
template <class T,unsigned int FIXED_BITS>
_ETL::fixed_base<T,FIXED_BITS>
abs(const _ETL::fixed_base<T,FIXED_BITS> &rhs)
{ return rhs<_ETL::fixed_base<T,FIXED_BITS>(0)?-rhs:rhs; }
_STD_END_NAMESPACE
/*
template <class T,unsigned int FIXED_BITS, typename U> bool
operator==(const _ETL::fixed_base<T,FIXED_BITS>& lhs, const _ETL::fixed_base<T,FIXED_BITS>& rhs)
{ return lhs.data()==rhs.data(); }
template <class T,unsigned int FIXED_BITS, typename U> bool
operator!=(const _ETL::fixed_base<T,FIXED_BITS>& lhs, const _ETL::fixed_base<T,FIXED_BITS>& rhs)
{ return lhs.data()!=rhs.data(); }
template <class T,unsigned int FIXED_BITS, typename U> bool
operator>(const _ETL::fixed_base<T,FIXED_BITS>& lhs, const _ETL::fixed_base<T,FIXED_BITS>& rhs)
{ return lhs.data()>rhs.data(); }
template <class T,unsigned int FIXED_BITS, typename U> bool
operator<(const _ETL::fixed_base<T,FIXED_BITS>& lhs, const _ETL::fixed_base<T,FIXED_BITS>& rhs)
{ return lhs.data()<rhs.data(); }
template <class T,unsigned int FIXED_BITS, typename U> bool
operator>=(const _ETL::fixed_base<T,FIXED_BITS>& lhs, const _ETL::fixed_base<T,FIXED_BITS>& rhs)
{ return lhs.data()>=rhs.data(); }
template <class T,unsigned int FIXED_BITS, typename U> bool
operator<=(const _ETL::fixed_base<T,FIXED_BITS>& lhs, const _ETL::fixed_base<T,FIXED_BITS>& rhs)
{ return lhs.data()<=rhs.data(); }
*/
#if defined(__GNUC__) && __GNUC__ == 3
template <class T,unsigned int FIXED_BITS, typename U> U
operator*(const U &a,const _ETL::fixed_base<T,FIXED_BITS> &b)
{ return a*static_cast<double>(b); }
template <class T,unsigned int FIXED_BITS, typename U> U
operator/(const U &a,const _ETL::fixed_base<T,FIXED_BITS> &b)
{ return a/static_cast<double>(b); }
template <class T,unsigned int FIXED_BITS, typename U> U
operator+(const U &a,const _ETL::fixed_base<T,FIXED_BITS> &b)
{ return a+static_cast<double>(b); }
template <class T,unsigned int FIXED_BITS, typename U> U
operator-(const U &a,const _ETL::fixed_base<T,FIXED_BITS> &b)
{ return a-static_cast<double>(b); }
/*
inline const float &
operator*=(float &a,const _ETL::fixed &b)
{ a*=(float)b; return a; }
inline const float &
operator/=(float &a,const _ETL::fixed &b)
{ a/=(float)b; return a; }
inline const float &
operator-=(float &a,const _ETL::fixed &b)
{ a-=(float)b; return a; }
inline const float &
operator+=(float &a,const _ETL::fixed &b)
{ a+=(float)b; return a; }
*/
#endif
/* === E N D =============================================================== */
#endif
|