Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

floating point

Name: Anonymous 2007-07-11 11:08 ID:1iiSAT9E

In the new C2009 standard, they should introduce an operator for floating point comparisons, to make up for the fact that == doesn't match numbers that are so very nearly the same (like, to 10 decimal places), but not equal.

As this new modern standard will support Ken Thompson's UTF-8 encoding, I would use the symbol "≈". For maximum flexibility, this will be both an infix operator and a function.

The function is defined as ≈(lvalue, rvalue, precision), where precision is an optional parameter specifying the number of binary places to compare. The operator assumes that precision is two binary places less than the least precise out of lvalue and rvalue (so if you're comparing a float and a double it'll take the precision of the float as a basis.)

What do you guys think of my proposal? I'm about to email it to Dennis Richie but am a bit delayed because pine only supports ASCII, so I'm recompiling it under Plan 9.

Name: Anonymous 2007-07-11 11:49 ID:L52R7elP

>>1
I don't like the idea much. First, the why is the first parameter an lvalue? It shouldn't be. Second, that's the same as doing l - r < precision, only you're bloating the language.

I'd write Ritchie to ask for true, specified Unicode support with UTF-8 and UTF-16 functions (not just vague refrences to "multibyte" and "wide" things), standard overflow testing, length-specified strings, and a safe standard library that doesn't scream "EXPLOIT ME LOL", including safer, proper, and more complete sscanf, sprintf, etc. functions; these would be my first priorities.

Right now the C standard library is so useless and the language is so limited that you have to implement your own language and libraries with it before doing any real work with it, save for small drivers.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List