两个不同的表达式导致c#和excel [英] Two different expression result in c# and excel

查看:109
本文介绍了两个不同的表达式导致c#和excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现一些非常奇怪的东西,如果我在excel和c#中使用下面的表达式,我会得到不同的结果。



(1)^( - 12)



Excel给出1和c#给出-11。



哪一个是对的?

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?

推荐答案

他们真的不同。难怪不同的表达会给出不同的结果,是吗? :-)



作为不同的表达方式,它们都是正确的,为什么不呢?在Excel中,''''表示power,在C#中,它表示异或(XOR)。请参阅:

http:/ /office.microsoft.com/en-us/excel-help/calculation-operators-and-precedence-HP010078886.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/zkacc7k1.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/6a71f45d.aspx [ ^ ]。



-SA
They are really different. It''s no wonder that different expressions give different results, is it? :-)

As different expressions, they are both "right", why not? In Excel, ''^'' means "power", in C#, it means "exclusive OR" (XOR). Please see:
http://office.microsoft.com/en-us/excel-help/calculation-operators-and-precedence-HP010078886.aspx[^],
http://msdn.microsoft.com/en-us/library/zkacc7k1.aspx[^],
http://msdn.microsoft.com/en-us/library/6a71f45d.aspx[^].

—SA


这篇关于两个不同的表达式导致c#和excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆