Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

What will be output? Expand / Collapse
Author
Message
Posted Monday, March 29, 2010 11:02 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, May 12, 2014 3:26 AM
Points: 136, Visits: 44
Nice Hint
Post #892457
Posted Tuesday, March 30, 2010 7:59 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Saturday, August 30, 2014 4:20 PM
Points: 11,194, Visits: 11,142
Seems I never get tired of getting this sort of question wrong



Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #892779
Posted Wednesday, March 31, 2010 2:59 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, August 16, 2012 10:11 PM
Points: 30, Visits: 31
Good Question
Post #893558
Posted Monday, April 5, 2010 3:32 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 5:59 PM
Points: 8,748, Visits: 9,296
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
Post #896591
Posted Wednesday, April 7, 2010 1:53 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 12:06 PM
Points: 148, Visits: 293
0 is false in this example
Post #898961
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse