Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

why doesn't ratio equal work?

$
0
0

* The following code example is taken from the book
 * "The C++ Standard Library - A Tutorial and Reference, 2nd Edition"
 * by Nicolai M. Josuttis, Addison-Wesley, 2012
 *
 * (C) Copyright Nicolai M. Josuttis 2012.
 * Permission to copy, use, modify, sell and distribute this software
 * is granted provided this copyright notice appears in all copies.
 * This software is provided "as is" without express or implied
 * warranty, and with no claim as to its suitability for any purpose.
 */
#include <ratio>
#include <iostream>
using namespace std;

int main()
{
   typedef ratio<5,3> FiveThirds;
   cout << FiveThirds::num << "/" << FiveThirds::den << endl;

   typedef ratio<25, 15> AlsoFiveThirds;
   cout << AlsoFiveThirds::num << "/" << AlsoFiveThirds::den << endl;
   cout<<boolalpha<< std::ratio_not_equal<ratio<5, 3>,  AlsoFiveThirds>::value << endl;

return 0;

}

When I run this code in VS2012, or VS2013 preview I get true meaning 5/3 != 25/15.  ratio_equal also yeilds a false result but ratio_less_equal and ratio_greater_equal seems to get the answer correct.  

Am I failing to understand something simple or is this a bug?

Thank you


Viewing all articles
Browse latest Browse all 15302


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>