March 29, 2010 at 11:02 pm
Nice Hint
March 30, 2010 at 7:59 am
Seems I never get tired of getting this sort of question wrong 🙁
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
March 31, 2010 at 2:59 am
Good Question
April 5, 2010 at 3:32 am
Hugo Kornelis (3/25/2010)
Good question, but unfortunately the explanation is not entirely correct. Especially this part is very misleading:Also the preceding space is not considered while performing the operation.
I agree. It's a good question and the answer is right, but that part of the explanation is wrong. Not sure why you say "especially that part". Are you suggesting that some other part is wrong too?
As you have seen, there is no leading space to be considered anywhere. However, even if there was, the words "is not considered" is misleading. I think we would all agree that converting the values '5', ' 5' and ' 5 ' to integer should all result in the value 5 - not because we expect the leading and trailing spaces to be "not considered", but because considering them or not is irrelevant, as they have no impact on the interpretation of the string as a number.
I don't much like saying that the reason ' 5 ' represents the integer 5 despite its having leading and trailing spaces is that "considering them or not is irrelevant"; the reason is that when we consider them we see that they have no impact on the interpretation of the string as a number - if we didn't consider them how would we know that they have no effect, that it was safe to say the string represents the number 5?
Tom
April 7, 2010 at 1:53 pm
0 is false in this example
Viewing 5 posts - 31 through 34 (of 34 total)
You must be logged in to reply to this topic. Login to reply