|
an old textbook way to improve your efficiency when your boss is using TLOC
using float will make him much more efficient.
|
|
|
|
|
From one of the articles on this very website a description of a function named Open:
Opens an existing WAV file. Returns a String, which will be blank upon success, and upon error, will contain the reason it failed. This method will throw an exception for a more serious error.
|
|
|
|
|
|
|
|
I think SQL Server calls that "Success with information".
|
|
|
|
|
All errors are equal, but some errors are more equal than others...
(yes|no|maybe)*
|
|
|
|
|
s_mon wrote: All errors are equal, but some errors are more equal than others...
Seems I've heard that before. Maybe at that farm I used to work at?
|
|
|
|
|
public int CharToInt(char pcChar)
{
switch(pcChar)
{
case '0' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '1' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '2' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '3' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '4' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '5' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '6' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '7' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case '8' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
case 'A' :
return 10;
break;
case 'B' :
return 11;
break;
case 'C' :
return 12;
break;
case 'D' :
return 13;
break;
case 'E' :
return 14;
break;
case 'F' :
return 15;
break;
default :
return 0;
}
}
|
|
|
|
|
Please,
Show some mercy and give the coder this:
String Test = "1Fa";
int Answer = int.Parse(Test, NumberStyles.HexNumber);
Steve Wellens
|
|
|
|
|
C#? how about some good ol'
ans = c_val > '9' ? (10 + c_val - 'A') : c_val-'0';
|
|
|
|
|
What's he/she got against the number 9?
Regards
David R
|
|
|
|
|
riced wrote: What's he/she got against the number 9?
Oh, nothing. 9 will get flipped to 6 automagically
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Issue this guy a prescription for a book that covers basic things like this... Good God, is this another guy who thinks he gets a bonus for writing the most (inefficient) code?
|
|
|
|
|
return ( "0123456789ABCDEF".IndexOf ( pcChar ) ) ;
Though it still doesn't support lowercase letters.
|
|
|
|
|
that does not return the right default value though.
|
|
|
|
|
|
What about ... ?
return ( "0123456789ABCDEF".IndexOf ( pcChar.ToUpper ) ) ;
|
|
|
|
|
Never mind the verbose and unoptimized bulk, smell the uncessary (and complained-about-by-the-compiler)
case '0' :
return Convert.ToInt32(Convert.ToString(pcChar));
break;
I love the smell of crap code in the morning...
|
|
|
|
|
My real problem here is that the autor of the code didn't test EVERY possible character. After all, using default to return an useless and invalid value is not a good idea.
It will be much better to:
case 'G':
throw new Exception("G is an invalid value.");
.
.
.
case 'Z':
throw new Exception("Z is an invalid value.");
LOL
|
|
|
|
|
If you are going to be paid by the line, then you should continue this with lower case, punctuation and the other oddities available in the local character set...
It would have been far to easy too write
default:
{
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
}
So we won't mention it.
Or at least I won't.
Oh bum.
modified on Sunday, April 19, 2009 5:44 AM
|
|
|
|
|
Except I just realized that to fit with his "coding style" I should have suggested
default:
{
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
return pcChar;
break;
}
I feel better now.
Unclean, but better.
|
|
|
|
|
default:
{
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
return pcChar;
break;
}
I must agree. This is a much better option. But I will keep the idea of checking each value, and ALSO use this pattern. So:
case 'G':
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
return pcChar;
break;
case 'H':
throw new Exception(string.Format("\"{0}\" is an invalid value", pcChar));
return pcChar;
break;
As this is the original pattern from 0 to 8 (9 is NOT a number, LOL).
|
|
|
|
|
|
Why not check if the char equal 10? And since your getting payed by line go on till you reach the max value of an int64?
Cheers
|
|
|
|