Click here to Skip to main content
15,887,083 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
JokeRe: zero int? Pin
harold aptroot23-Nov-11 8:01
harold aptroot23-Nov-11 8:01 
JokeRe: zero int? Pin
Stefan_Lang12-Dec-11 6:18
Stefan_Lang12-Dec-11 6:18 
GeneralRe: zero int? Pin
BobJanova23-Nov-11 5:14
BobJanova23-Nov-11 5:14 
GeneralRe: zero int? Pin
CDP180223-Nov-11 5:17
CDP180223-Nov-11 5:17 
GeneralRe: zero int? Pin
AspDotNetDev23-Nov-11 6:45
protectorAspDotNetDev23-Nov-11 6:45 
GeneralRe: zero int? Pin
harold aptroot23-Nov-11 7:24
harold aptroot23-Nov-11 7:24 
GeneralRe: zero int? Pin
AspDotNetDev23-Nov-11 11:08
protectorAspDotNetDev23-Nov-11 11:08 
GeneralRe: zero int? Pin
KP Lee3-Dec-11 1:51
KP Lee3-Dec-11 1:51 
I'm not sure if float will represent an entered 0 as all "bits" 0. It's the only time the value will be all zero bits. I can't remember if the exponent value is 0 or 1, but in either case, I think the exponent needs at least 1 bit to be set to 1.

In any case, the -0 concept has nothing to do with float types. It's for signed integers in a 1's comp environment. I'm not sure if 1's comp was still being produced 30 years ago, I do know I learned about it around 1979 and it was known then how poor that mathematical model was.

Basically -0 is produced by having all 1's set in a signed integer. You get it by first getting a negative number and then adding to reach 0. In 1's comp, every negative number is the exact complement of the same positive number. (Position to position every 1 bit is set to 0 and every 0 bit is set to 1 to change from a positive number to the same negative number.

In 1's comp, the 1's bit is on for odd positive numbers and off for odd negative numbers. In 2's comp the 1's bit is on for both positive and negative numbers.
GeneralRe: zero int? Pin
harold aptroot3-Dec-11 2:14
harold aptroot3-Dec-11 2:14 
AnswerRe: zero int? Pin
Nagy Vilmos21-Nov-11 23:52
professionalNagy Vilmos21-Nov-11 23:52 
GeneralRe: zero int? Pin
CDP180221-Nov-11 23:57
CDP180221-Nov-11 23:57 
GeneralRe: zero int? Pin
Nagy Vilmos21-Nov-11 23:58
professionalNagy Vilmos21-Nov-11 23:58 
GeneralRe: zero int? Pin
CDP180222-Nov-11 0:08
CDP180222-Nov-11 0:08 
GeneralRe: zero int? Pin
PIEBALDconsult22-Nov-11 1:51
mvePIEBALDconsult22-Nov-11 1:51 
GeneralRe: zero int? Pin
CDP180222-Nov-11 2:24
CDP180222-Nov-11 2:24 
GeneralRe: zero int? Pin
Reiss22-Nov-11 2:45
professionalReiss22-Nov-11 2:45 
GeneralRe: zero int? Pin
CDP180222-Nov-11 2:52
CDP180222-Nov-11 2:52 
GeneralRe: zero int? PinPopular
harold aptroot22-Nov-11 2:57
harold aptroot22-Nov-11 2:57 
GeneralRe: zero int? Pin
Reiss22-Nov-11 5:20
professionalReiss22-Nov-11 5:20 
GeneralRe: zero int? Pin
harold aptroot22-Nov-11 0:36
harold aptroot22-Nov-11 0:36 
GeneralRe: zero int? Pin
BobJanova22-Nov-11 0:38
BobJanova22-Nov-11 0:38 
AnswerRe: zero int? Pin
Fabio Franco23-Nov-11 7:16
professionalFabio Franco23-Nov-11 7:16 
AnswerRe: zero int? Pin
KP Lee3-Dec-11 11:18
KP Lee3-Dec-11 11:18 
RantWhy SQL Server sucked on Friday Pin
Gary R. Wheeler20-Nov-11 5:45
Gary R. Wheeler20-Nov-11 5:45 
GeneralRe: Why SQL Server sucked on Friday Pin
OriginalGriff20-Nov-11 6:07
mveOriginalGriff20-Nov-11 6:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.