Question posted 2013 · +3 upvotes
I find something really weird, if I used below expression in excel and c# I get different results.
(1) ^ (-12)
Excel gives 1 and c# gives -11.
Which one is right one?
Accepted answer +19 upvotes
In Excel ^ means exponentiation. In C# it means bitwise exclusive or. They are completely different operations; it is just a coincidence that they use the same symbol.
Use Math.Pow for exponentiation in C#.
Top excel Q&A (6)
- Shortcut to Apply a Formula to an Entire Column in Excel +335 (2011)
- How should I escape commas and speech marks in CSV files so they work in Excel? +136 (2012)
- Convert xlsx to csv in linux command line +96 (2012)
- How to create a link inside a cell using EPPlus +50 (2011)
- IF statement: how to leave cell blank if condition is false ("" does not work) +44 (2013)
- T-SQL: Export to new Excel file +44 (2012)
excel solutions on this site
— top 18%.