Hacker News new | ask | show | jobs
by CodeMage 5104 days ago
I'm genuinely curious here: why would using integers be slower than using floats? I thought floating point operations were always more expensive than handling ints.
1 comments

For simple accounting, it wouldn't be slower. The issue is analytical code, e.g.:

    int price = getPrice(symbol);
    double signal = exp(...) * ((double)price);
    if (signal > threshold) {
        buy(symbol);
    }
The point is to avoid converting from int to double every single time you need to do a calculation.