3 ms·
Idiomatic C would say: float discrim = b*b - 4*a*c; Using pow for a small integer power is a no-no: less efficient and less accurate. I agree that \ is an
by dzdt 9y ago
Idiomatic C would say:
float discrim = b*b - 4*a*c;
Using pow for a small integer power is a no-no: less efficient and less accurate.
I agree that \ is an awkward choice. A Fortran-like double asterisk ∗∗ is out because of ambiguity with pointers; single caret ^ out because it is already reserved for bitwise xor. Maybe double caret ^^ or asterisk-caret ∗^ could be used? That would read okay :
double discrim = b^^2 - 4*a*c;
double discrim = b*^2 - 4*a*c;
- jcelerier 9y ago> Using pow for a small integer power is a no-no: less efficient and less accurate. Using pow for a small integer power compiles into the exact same code: https://godbolt.org/g/CjoHdJ https://godbolt.org/g/CjoHdJ
- stochastic_monk 9y agoOnly for 1 or 2, unless you turn on --fast-math.
- tejasmanohar 9y agoUsing pow for a small integer power is a no-no: less efficient and less accurate. I think you missed the point.