[ quantlib-Bugs-1826937 ] < operator in Period class incorrect

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ quantlib-Bugs-1826937 ] < operator in Period class incorrect

SourceForge.net
Bugs item #1826937, was opened at 2007-11-06 16:49
Message generated for change (Comment added) made by lballabio
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=1826937&group_id=12740

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Luigi Ballabio (lballabio)
Summary: < operator in Period class incorrect

Initial Comment:
The following code incorrectly throws an "undecidable" comparison.


// Demonstrates false undecidability in Period.
#include <iostream>
#include <ql/quantlib.hpp>

using namespace std;
using namespace QuantLib;


int main (int argc, char * const argv[]) {
  Period p3m(3, Months), p1w(1, Weeks);
               
  cout<<"Hello, World! " << p3m << ", " << p1w << endl;
               
  bool bigGTsmall = p3m > p1w;
  cout << "bigGTsmall = " << bigGTsmall << endl;

  // next comparison throws "undecidable comparison"
  bool bigLTsmall = p3m < p1w;
  cout << "bigLTsmall " << bigLTsmall << endl;
               
  return 0;
}

I've attached a possible fix, coded for clarity.  (The original comparison code in the Period class has a significant number of nested ifs and switches).

Best,

[hidden email]

----------------------------------------------------------------------

Comment By: Luigi Ballabio (lballabio)
Date: 2007-11-07 12:39

Message:
Logged In: YES
user_id=75450
Originator: NO

The bug is now fixed in CVS.
Thank you for the report.


----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=112740&aid=1826937&group_id=12740

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev