Piotr
Piotr

Reputation: 39

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.

Upvotes: 0

Views: 81

Answers (1)

Davide Spataro
Davide Spataro

Reputation: 7482

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)

Upvotes: 2

Related Questions