Mercurial > octave-nkf
comparison liboctave/oct-inttypes.h @ 5030:160365410ad4
[project @ 2004-09-24 03:22:23 by jwe]
author | jwe |
---|---|
date | Fri, 24 Sep 2004 03:22:24 +0000 |
parents | 1ec26bdb120c |
children | 97b62f0c1bee |
comparison
equal
deleted
inserted
replaced
5029:1ec26bdb120c | 5030:160365410ad4 |
---|---|
256 OCTAVE_INT_FIT_TO_RANGE (- static_cast<double> (ival), T) : 0; | 256 OCTAVE_INT_FIT_TO_RANGE (- static_cast<double> (ival), T) : 0; |
257 } | 257 } |
258 | 258 |
259 operator double (void) const { return static_cast<double> (value ()); } | 259 operator double (void) const { return static_cast<double> (value ()); } |
260 | 260 |
261 operator float (void) const { return static_cast<float> (value ()); } | |
262 | |
261 octave_int<T>& operator += (const octave_int<T>& x) | 263 octave_int<T>& operator += (const octave_int<T>& x) |
262 { | 264 { |
263 double t = static_cast<double> (value ()); | 265 double t = static_cast<double> (value ()); |
264 double tx = static_cast<double> (x.value ()); | 266 double tx = static_cast<double> (x.value ()); |
265 ival = OCTAVE_INT_FIT_TO_RANGE (t + tx, T); | 267 ival = OCTAVE_INT_FIT_TO_RANGE (t + tx, T); |
337 | 339 |
338 retval = a; | 340 retval = a; |
339 | 341 |
340 b_val -= 1; | 342 b_val -= 1; |
341 | 343 |
342 while (b_val) | 344 while (b_val != zero) |
343 { | 345 { |
344 if (b_val & one) | 346 if ((b_val & one) != zero) |
345 retval = retval * a_val; | 347 retval = retval * a_val; |
346 | 348 |
347 b_val = b_val >> 1; | 349 b_val = b_val >> 1; |
348 | 350 |
349 if (b_val > zero) | 351 if (b_val > zero) |
466 template <class T> \ | 468 template <class T> \ |
467 bool \ | 469 bool \ |
468 operator OP (const octave_int<T>& x, const double& y) \ | 470 operator OP (const octave_int<T>& x, const double& y) \ |
469 { \ | 471 { \ |
470 double tx = static_cast<double> (x.value ()); \ | 472 double tx = static_cast<double> (x.value ()); \ |
471 return tx OP y.value (); \ | 473 return tx OP y; \ |
472 } | 474 } |
473 | 475 |
474 OCTAVE_INT_DOUBLE_CMP_OP (<) | 476 OCTAVE_INT_DOUBLE_CMP_OP (<) |
475 OCTAVE_INT_DOUBLE_CMP_OP (<=) | 477 OCTAVE_INT_DOUBLE_CMP_OP (<=) |
476 OCTAVE_INT_DOUBLE_CMP_OP (>=) | 478 OCTAVE_INT_DOUBLE_CMP_OP (>=) |
482 template <class T> \ | 484 template <class T> \ |
483 bool \ | 485 bool \ |
484 operator OP (const double& x, const octave_int<T>& y) \ | 486 operator OP (const double& x, const octave_int<T>& y) \ |
485 { \ | 487 { \ |
486 double ty = static_cast<double> (y.value ()); \ | 488 double ty = static_cast<double> (y.value ()); \ |
487 return y.value () OP ty; \ | 489 return x OP ty; \ |
488 } | 490 } |
489 | 491 |
490 OCTAVE_DOUBLE_INT_CMP_OP (<) | 492 OCTAVE_DOUBLE_INT_CMP_OP (<) |
491 OCTAVE_DOUBLE_INT_CMP_OP (<=) | 493 OCTAVE_DOUBLE_INT_CMP_OP (<=) |
492 OCTAVE_DOUBLE_INT_CMP_OP (>=) | 494 OCTAVE_DOUBLE_INT_CMP_OP (>=) |
509 | 511 |
510 template <class T1, class T2> | 512 template <class T1, class T2> |
511 octave_int<T1> | 513 octave_int<T1> |
512 operator << (const octave_int<T1>& x, const T2& y) | 514 operator << (const octave_int<T1>& x, const T2& y) |
513 { | 515 { |
514 T1 retval = x; | 516 octave_int<T1> retval = x; |
515 return retval <<= y; | 517 return retval <<= y; |
516 } | 518 } |
517 | 519 |
518 template <class T1, class T2> | 520 template <class T1, class T2> |
519 octave_int<T1> | 521 octave_int<T1> |
520 operator >> (const octave_int<T1>& x, const T2& y) | 522 operator >> (const octave_int<T1>& x, const T2& y) |
521 { | 523 { |
522 T1 retval = x; | 524 octave_int<T1> retval = x; |
523 return retval >>= y; | 525 return retval >>= y; |
524 } | 526 } |
525 | 527 |
526 template <class T> | 528 template <class T> |
527 octave_int<T> | 529 octave_int<T> |