views:

253

answers:

5
Gain = 255 / (1 - 10 ^ ((Refblack-Refwhite) * 0.002/0.6) ^ (Dispgamma/1.7))

Is that a computer language, it looks like c but exclusive or floats doesnt compute. Can anybody convert that to c?

thanks

+3  A: 
gain = 255.0 / (1.0 - pow(10.0,  pow((Refblack - Refwhite) * 0.002 / 0.6, Dispgamma / 1.7) ))
Didier Trosset
+7  A: 

In many languages, ^ is exponentiation. That's the pow(), which has the following prototype in math.h>:

double pow(double x, double y);

This computes x raised to the y:th power. So, this makes the equation convert to:

#include <math.h>

Gain = 255 / (1 - pow(10, pow(((Refblack-Refwhite) * 0.002/0.6), (Dispgamma/1.7))));
unwind
+2  A: 
Gain = 255 / (1 - pow(10 , ( pow( (Refblack-Refwhite) * 0.002/0.6) , (Dispgamma/1.7)) ) )
codaddict
+4  A: 

I guess they mean: Gain = 255 / (1.0 - powf(10, powf((Refblack-Refwhite) * 0.002/0.6), Disgamma/1.7)))

Because ^ is normaly xor operator in C. As others used pow it will only use int:s and return a int. man 3 pow for more information.

emil
Both `pow` and `powf` operate on floating-point data, not integers. `pow` is for double-precision floats, `powf` for single-precision.
Stephen Canon
+2  A: 

Looks like Matlab code to me

in C, something like that

#include <math.h>

float Gain=0;
...
Gain = 255 / (1 - powf(10, powf(((Refblack-Refwhite) * 0.002/0.6), (Dispgamma/1.7));
petantik