![]() |
Using two hyphens in front of an Excel function.
Yesterday I saw an Excel function that had two hyphens "--" before the
function name. I do remember reading about this a few months ago but I do not remember the use. I was NOT double negation as I remember well. There was another obscur use. Anybody has an idea? Thanks -- Daniel |
Using two hyphens in front of an Excel function.
To convert True to 1 and False to 0 so that maths can be done on them. -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=126935 |
Using two hyphens in front of an Excel function.
The double negation (changes the sign from positive to negative and
then negative to positive) is one way to convert the TRUE or FALSE result of a comparison operation to the numeric equivalent (TRUE = 1, FALSE = 0). Basically, it multiplies the TRUE or FALSE by -1 twice, which forces Excel to change the value to a number. Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Wed, 19 Aug 2009 15:12:24 -0700, dlamarche <Melbourne wrote: Yesterday I saw an Excel function that had two hyphens "--" before the function name. I do remember reading about this a few months ago but I do not remember the use. I was NOT double negation as I remember well. There was another obscur use. Anybody has an idea? Thanks |
Using two hyphens in front of an Excel function.
"dlamarche" <Melbourne wrote:
Yesterday I saw an Excel function that had two hyphens "--" before the function name. I do remember reading about this a few months ago but I do not remember the use. I was NOT double negation as I remember well. There was another obscur use. Anybody has an idea? Yes, it __is__ simply double negation. Sometimes it is used to convert "numeric text" or Boolean values (TRUE, FALSE) to bona fide numbers. But any arithmetic operation will do the trick. Double negation per se is not always necessary. For example, consider =TEXT(A1,"hh:mm"), which might be used to round a time value in A1 to the precision of a minute. The TEXT function itself returns a string. If you want a time value (a number), you can use double negation, to wit: =--TEXT(A1,"hh:mm"). But suppose you want to add 1 minute to the rounded time value. It would be sufficient to do: =TEXT(A1,"hh:mm")+TIME(0,1,0). PS: Even where double negation is useful, there are alternatives. =1*TEXT(A1,"hh:mm") is equivalent to =--TEXT(A1,"hh:mm"). |
Using two hyphens in front of an Excel function.
Thanks you very much for the info gentlemen. I was very intriged but now it
is clearer. So -- was a double negation after all. Thanks Chip, I visit your site regularly and recommended it to many of my students! -- Daniel "JoeU2004" wrote: "dlamarche" <Melbourne wrote: Yesterday I saw an Excel function that had two hyphens "--" before the function name. I do remember reading about this a few months ago but I do not remember the use. I was NOT double negation as I remember well. There was another obscur use. Anybody has an idea? Yes, it __is__ simply double negation. Sometimes it is used to convert "numeric text" or Boolean values (TRUE, FALSE) to bona fide numbers. But any arithmetic operation will do the trick. Double negation per se is not always necessary. For example, consider =TEXT(A1,"hh:mm"), which might be used to round a time value in A1 to the precision of a minute. The TEXT function itself returns a string. If you want a time value (a number), you can use double negation, to wit: =--TEXT(A1,"hh:mm"). But suppose you want to add 1 minute to the rounded time value. It would be sufficient to do: =TEXT(A1,"hh:mm")+TIME(0,1,0). PS: Even where double negation is useful, there are alternatives. =1*TEXT(A1,"hh:mm") is equivalent to =--TEXT(A1,"hh:mm"). |
All times are GMT +1. The time now is 10:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com