/*
 * Simple program to demonstrate floating point bug in GNU C++ on
 * Intel hardware with Linux.
 *
 * Compile with:
 *  - g++ -o wtf wtf.cc
 *
 * Then run.  Be surprised.
 *
 * Now compile with:
 *  - g++ -O2 -o wtf wtf.cc
 *
 * Now run.  Be more surprised.
 *
 * From: http://gcc.gnu.org/ml/gcc-help/2001-06/msg00053.html
 */

#include <stdio.h>

int main(int argc, char *argv[])
{
    double  amount;
    double  cost;
    long long    iamount;

    cost = 0.06;
    amount = cost * 100;
    iamount = cost * 100;

    // should print "Amount (double) 6.00000"
    printf("Amount (double) %lf\n", amount);

    // should print "Amount (long long) 6"
    // does it?
    printf("Integer Amount (long long) %lld\n", iamount);

    return (0);
}
