# Data Types

Hi! I’m trying to make a calculation, but the answer isn’t right.
It should be 2592788242.73, but get 2592788224.

Here’s the code:

``````void main()
{
unsigned long a;
a = test(37.325, 180.0, -180.0);
}

unsigned long test (double value, double maximum, double minimum)
{
unsigned long ret;

if( value &gt; maximum )
value = maximum;
if( value &lt; minimum )
Vavaluelor = minimum;

ret = ((value - minimum) * 4294967295) / (maximum - minimum);

return ret;
}
``````

Am I using the wrong data type?

Thanks!

You’re losing precision in your constant. Try this:

``````	double multi;

multi = 4294967295.0;
printf("multi = %f
", multi);

``````

I get multi = 4294967290.000000 in the printout.

According to the Dynamic C manual, float and double are both 32-bit values.

Environment DC 9.62

Code:
double a;

a=217347.620000;
printf("%f
“,a);
a=2666813.350000;
printf(”%f
“,a);
a=217349.520000;
printf(”%f
“,a);
a=2666813.350000;
printf(”%f
“,a);
a=217350.220000;
printf(”%f
",a);

Result:
217347.625000
2666813.250000
217349.515000
2666813.250000
217350.218000