Andrew Lentvorski wrote:
Christopher Smith wrote:
If only C had things like function pointers/callbacks, variables like
errno that could indicate an error, or functions you could call to
verify that you didn't get a certain error since your last checkpoint
(or the last operation). Oh wait... ;-)
And that would be a very real performance hit.
If you need to check errno every arithmetic call, that would actually
create a synchronization point which *would* destroy performance. I
seem to recall that checking errno always requires a memory barrier.
What you are actually doing is checking the value in a register, so you
don't need a synchronization point. What we're talking about is a single
instruction, whose negative performance impact may be no more than the
space it takes up in memory. How this is represented in the language is
immaterial as long as the compiler knows how to translate it to the
appropriate action. BTW, as far as errno goes, most thread-safe
implementations of libc put errno in thread local store, so no
synchronization is needed to access it.
I work with folks who do binary floating point just fine every day. ;-)
That said, it takes people a while to get the gist of floating point
math, regardless of whether it's in base 2 or base 10.
So, tell us where you work. I stand in awe.
Yahoo. Not that there aren't people who screw up there use of floating
point math at Yahoo, but the folks I work with don't have much problem
with it. For the most part, the real pain of doing floating point in
base 2 comes from all the cases where people want to translate them to
in to a decimal world. If you use the floating point values exclusively
inside the machine (for example as one might with machine learning or
linear programming), the only thing you really have to sensitive about
is precision/rounding.
--Chris
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg