Piotr Piotr - 3 years ago 155
C Question

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. 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.

Answer Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download