1. ## Problems with addition of float variables

When incrementing the float variable cf using one of the two statements

cf=cf+5;

or

cf=cf+inc;

where inc is a float variable that was set equal to 5

the value of cf is increased, but it is increased by a value other than 5

2. I've never heard or seen of this but try adding a decimal point to the end and/or 'f'

Code:
`float var = 5.0f;`

3. Ok, here is some of the code:

int y;
float cf, inc, data;
char temp, ccf; //used as array

....

cf=300;
inc=5;

for (y=0; y<=3; y++)
{
printf("%f", cf); //to test the code
sprintf(ccf, "CF %fMZ", cf);

ibwrt(sa, ccf, 20L); //writes assembly to a GPIB bus
sleep(1);

ibwrt(sa, "E1", 2L);
ibwrt(sa, "MA", 2L);
ibrd(sa, temp, 8L);

sscanf(temp, "%f", &data);

fprintf(dataout, "%f\n", data); //dataout defined elsewhere

cf = cf + inc;
}

when running this segment of code, the printf statement at the beginning of the loop will print:

300
11,234,345 or similiar

I hope that helps.

Thanks.

4. i'm not really sure what's going on here.

But just to point out something (don't know if it'll have an effect or not...)

you initialized ccf as char
but using sprintf() you treated it like a string...

try
Code:
`char ccf[8];`
or if thats not enough
Code:
`char ccf[16];`
-LC

5. Code:
```float cf, inc, data;
char temp, ccf; //used as array

....

cf=300;
inc=5;
```
Why floats? cf and inc are not floats in this case, they are integers. Even though most smart compilers will convert them to floats 300.0f and 5.0f, you should do this yourself.

I don't understand why you are using - make that misusing -floats.

Again and again I've looked at this code and it looks like some attempt to write a crude compiler for something. Are you trying to place assembly opcodes directly into memory or something?? I'm totally lost.

6. Originally posted by Bubba
Why floats? cf and inc are not floats in this case, they are integers. Even though most smart compilers will convert them to floats 300.0f and 5.0f, you should do this yourself.

I don't understand why you are using - make that misusing -floats.

Again and again I've looked at this code and it looks like some attempt to write a crude compiler for something. Are you trying to place assembly opcodes directly into memory or something?? I'm totally lost.
Here's a hint: cf stands for center frequency. Want to take a guess what sa stands for?