- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
See, befunge-93 does this right. Whenever a division by zero is encountered, the user is simply asked what they want the result to be.
Admin
I lost you there. The original was:
epsilon * 2 ^ (log2(10) - 51)
which is roughly equivalent [1] to
epsilon * epsilon * 10
This could be fixed by replacing either epsilon with 1, or 51 with 0, which would give:
epsilon * 2 ^ (log2(10) - 0) // replace 51 with 0
or
1 * 2 ^ (log2(10)-51) // replace epsilon with 1
which are both equal to
epsilon * 10
[1] ignoring for the moment that epsilon is actually 2^-52, not 2^-51...only one correction per post ;-)
Admin
Actually, dividend is the proper word for a number that is divided. Numerator would apply more to fractions (which are same, I realize), but using the word 'dividend' is about the only thing that is correct in this code. (Notice, the correct term for a number that divides another number is 'divisor', not 'divider'. That's where the non-standard terminology comes in.)
Admin
Oh, sure, but you could always get around that like this:
As to why: ..........I got nothing.
;)
Admin
Considering the sign is the only thing it gets right, I guess it's worth going to at least a bit of trouble over :)
Admin
public Double ASimpleMindedAproachToDividing(Double Dividend, Double Divider) { /// this also keeps the signs correct. return ( Divider==0 ? Null : ( Dividend / Divider ) );
/// And it actually returns the correct value. }
Admin
It's simple:
addend + augend = sum
subtrahend - subtractor = difference
multiplicand * multiplier = product
dividend / divisor = quotient
....and yes, that's from memory. It might be wrong, but I'm pretty sure it's right. :)
Admin
You never dated the NaN I did, or you wouldn't talk like that - and I think you hit your caps lock key by mistake...
Admin
One Big Regret.
He did it in a separate function. He didn't overload the division operator. Now that would have been beautiful.
Admin
Humans don't need to read this. My IntelliSense needs to read it. And it can't read your comments, but it can read the original documentation.
Note the subtle difference...
Admin
Admin
Could be he used those powers of ten to avoid problems with the fact that some simple decimal fractions (like 0.1) are infinitely repeating binary floating point values. Decimal 0.1 is binary 0.00011001100110011........
Admin
I don't know about C#, but in Java your code would not compile, since Random is a random number generator, not a number.
Admin
Java will only divide by zero safely if one of the values is a double (it doesn't matter which), when it automatically casts the other to a double as well. If you try to use integer division by zero, Java throws a java.lang.ArithmeticException
Admin
Admin
What??? Did you see the code? Please, don't!!!
Admin
AS you've demonstrated, this only works with floats, as ints will still throw.
Admin
While "augend" is perfectly acceptable, it was coined during the Renaissance period and is rarely used in modern times. "Addend" (short for "Addendum", which is also perfectly valid) is the most commonly used term now.
Admin
I just read the article in the link, quite interesting.
Such situation that enables division by zero should never happen. Even if a new number( 'nullity') is introduced, it just keep the program running in a crazy way, so even if the autopilot does not stop, your plane will crash into a mountain. Even if the pace maker still runs, your heart will beat with the frequency of Micro-processor ROFL
Admin
Iz in yur functionz returnin incorrect doublzzzz.
Admin
0/0.. OH SHI-
Admin
Actually, "augend" wasn't coined during the Renaissance - it fell out of favour during the Renaissance. And the first two equations are incorrect. The list should be:
augend + addend= sum minuend - subtrahend = difference multiplicand * multiplier = product dividend / divisor = quotient
My first post here, and all I can say about what I just wrote is WTF?!
Admin
Dr. Anderson isn't the only one who did work on this subject. There's a Robert Miller in the United States who wrote a paper using similar arguments about what Anderson calls Nulity. Really cool read! He conects it to extra dimension and time. http://www.vixra.org/abs/1302.0036