Two different expression result in c# and excel

calendar_today Asked Apr 24, 2013
thumb_up 19 upvotes
history Updated April 16, 2026

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)

+19 upvotes ranks this answer #30 out of 167 excel solutions on this site — top 18%.