简体   繁体   English

C中运算符前面的点是什么意思?

[英]What does the dot preceeding an operator mean in C?

I'm not familiar with C and I'm trying to translate a piece of code I found to another language. 我对C不熟悉,我试图将我发现的一段代码翻译成另一种语言。 For the most part, it's been rather intuitive but now i encountered a bit of code in which a subtraction operator is preceeded by a fullstop, like this: 在大多数情况下,它相当直观,但是现在我遇到了一些代码,其中减号运算符以句号开头,如下所示:

double C;
C = 1.-exp(A/B)

I searched for it but all I can find about the dot operator is the standard property access of an object. 我进行了搜索,但是我能找到的关于点运算符的只是对象的标准属性访问。 I've encountered the '.-' operator in other langauges where it denoted element-wise operation on an array, but in my code none of the elements are arrays; 我在其他语言中遇到过'.-'运算符,它表示对数组进行按元素操作,但是在我的代码中,所有元素都不是数组; all of A, B and C are doubles. A,B和C均为双打。

It instructs the compiler to treat that literal number as a floating-point number. 它指示编译器将该文字数字视为浮点数 1. = 1.0

  • In your case C = 1.-exp(A/B) is equivalent to C = 1.0 -exp(A/B) 在您的情况下C = 1.-exp(A/B) C = 1.0 -exp(A/B)等效于C = 1.0 -exp(A/B)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM