Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-06-2011, 04:09 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline meaning and use of  -- in excel Windows 7 32bit meaning and use of  -- in excel Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

It's also very commonly used in SUMPRODUCT().



SUMPRODUCT() can only process numbers; you'll often find that you have a situation where you have an array of booleans which need to be coerced into numbers so that SUMPRODUCT() can use them. This can be done by performing a simple arithmetic operation on them. For example:

TRUE+0 coerces TRUE to 1
TRUE-0 coerces TRUE to 1
TRUE*1 coerces TRUE to 1
TRUE/1 coerces TRUE to 1

(and many more).

You'll be familiar with addition, subtraction, multiplication and division as shown above. There's also negation which is achieved by applying the unary minus operator:

-TRUE coerces TRUE to -1
--1 gives 1

so

--TRUE coerces TRUE to 1



When people choose how to do the coercion they could use any of these options, but many people decide to use two unary minus operators. This is for 2 reasons:
(1) Unary minus sits high up on the operator precedent list
(2) Double negation is marginally faster to calculate than the other options


Some further reading for you:
SUMPRODUCT
Array Formulas (see particularly post #5)


Hope that helps...
Colin
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
meaning and use of  -- in excel VBA code from Excel 2007 in Excel 2010 csam63 Excel Programming 1 10-07-2011 10:46 AM
meaning and use of  -- in excel where we can find the meaning for all the marks that Word uses? Jamal NUMAN Word 2 06-26-2011 09:49 AM
meaning and use of  -- in excel Excel Hyperlinks crash Excel programme martinlest Excel 8 01-26-2011 04:23 AM
meaning and use of  -- in excel Opening multiple Excel files within the same Excel window. lost9471 Excel 2 05-01-2010 01:57 PM
How do I use an Excel form to populate and Excel spreadsheet apostht Excel 0 05-21-2006 11:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft