Need Help to Understand the follow code
-
Saturday, April 14, 2012 3:06 PM
All Replies
-
Saturday, April 14, 2012 4:00 PM
It seems to do something like this.
Working from the inside to outside:
X: num2 = Single.MinValue - test which is either True or False,
Y: X > False - test is the result of X positive, which will give True or False
Z: make the result of Y negative, that does not mean turn it from True to False or vice versa
Convert the result of Z to a Single.I suspect it is relying on False being 0, and True being something that is non-zero. I'd guess it means something like: If num2 <> MinValue then num=0 else num = -1 (or possibly num =1, depending how False is represented).
Regards David R
---------------------------------------------------------------
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
Every program eventually becomes rococo, and then rubble. - Alan Perlis
The only valid measurement of code quality: WTFs/minute.- Proposed As Answer by Mark Liu-lxfModerator Monday, April 16, 2012 9:27 AM
- Marked As Answer by Mark Liu-lxfModerator Tuesday, April 24, 2012 8:23 AM
-
Saturday, April 14, 2012 7:41 PM
That sure is one ugly line of code.
Sub UglyCode(ByVal num2 As Single) Dim num As Single = CSng(-((num2 = Single.MinValue) > False)) End Sub Sub UglierCode(ByVal num2 As Single) Dim X As Boolean = (num2 = Single.MaxValue) Dim Y As Boolean = (X > False) Dim Z As Boolean = -Y Dim num As Single = CSng(Z) End Sub
Rudy =8^DMark the best replies as answers. "Fooling computers since 1971."
- Proposed As Answer by Mark Liu-lxfModerator Monday, April 16, 2012 9:27 AM
- Marked As Answer by Mark Liu-lxfModerator Tuesday, April 24, 2012 8:23 AM

