Free Republic
Browse · Search
News/Activism
Topics · Post Article

To: JamesP81
It would be given an arbitrary value that wouldn't be used in any other fashion in that software.

If you divide an integer by an integer in your computer program you will get an integer result. Integers represent positive and negative numbers. For a 32-bit integer this means a range of –2,147,483,648 to 2,147,483,647. Those values use every single one of the 32 bits. How are you going to now represent "nullity" with "an arbitrary value" that will be returned when you divide by zero?

71 posted on 12/08/2006 12:56:58 PM PST by vrwc1
[ Post Reply | Private Reply | To 49 | View Replies ]


To: vrwc1
How are you going to now represent "nullity" with "an arbitrary value" that will be returned when you divide by zero?

Declare the pointer to the value to be null after exception handling the divide by zero error. Either that, or we determine that the lowest value for a given variable or its highest possible value (either –2,147,483,648 or 2,147,483,647 since we're using 32 bit signed integers) to be a divide by zero condition. This is only if you need to look back later in the code to see if a divide by zero occurred. Normally, exception handling at the time of the error is sufficient and such methods aren't necessary, but they are available if needed and I've used them on more than one occasion.
100 posted on 12/08/2006 1:08:27 PM PST by JamesP81 (If you have to ask permission from Uncle Sam, then it's not a right)
[ Post Reply | Private Reply | To 71 | View Replies ]

To: vrwc1
If you divide an integer by an integer in your computer program you will get an integer result.

I almost overlooked this. When a computer does integer division it does yield integer results. Except when it divides by zero. This usually pitches an exception error. You deal with it using exception handlers and, as part of the exception handler, you set your variable storing the answer to formula that divided by zero to null or your arbitrary value like I talked about in post #100. At least you'd better use exception handlers, because if you don't, that pacemaker the article talks about gets a BSOD and someone's heart stops.
112 posted on 12/08/2006 1:14:17 PM PST by JamesP81 (If you have to ask permission from Uncle Sam, then it's not a right)
[ Post Reply | Private Reply | To 71 | View Replies ]

To: vrwc1
If you divide an integer by an integer in your computer program you will get an integer result.

You mean a rational result, right? 2 divided by 3 does not yield an integer.
178 posted on 12/08/2006 2:00:04 PM PST by Stone Mountain
[ Post Reply | Private Reply | To 71 | View Replies ]

To: vrwc1
If you divide an integer by an integer in your computer program you will get an integer result. Integers represent positive and negative numbers. For a 32-bit integer this means a range of –2,147,483,648 to 2,147,483,647. Those values use every single one of the 32 bits. How are you going to now represent "nullity" with "an arbitrary value" that will be returned when you divide by zero?

The same way you represent the square root of -1 as i.

Or the same way you represent the perimeter of a circle divided by the radius as p.

246 posted on 12/08/2006 3:04:35 PM PST by FreedomCalls (It's the "Statue of Liberty," not the "Statue of Security.")
[ Post Reply | Private Reply | To 71 | View Replies ]

Free Republic
Browse · Search
News/Activism
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson