Hi,
Below is a part of my program:
int f, location1, location2;
float ans;
float heartrate;
f = abs (location1 - location2);
heartrate = ((f*5)/1000);
ans = 1/heartrate;
There is a problem getting a correct float value of heartrate because f is an integer.
How can i get the correct float number?
problem of conversion
Re: problem of conversion
Hi,
Is this MikroPascal Pro or MikroC Pro ?
Do not use "f" use something other for example "fff".
Best regards,
Peter
Is this MikroPascal Pro or MikroC Pro ?
Do not use "f" use something other for example "fff".
Best regards,
Peter
Re: problem of conversion
Hi,
it is mikcroC. it will be able to solve the problem by changing f to fff?
it is mikcroC. it will be able to solve the problem by changing f to fff?
Re: problem of conversion
Hi,
The f should behave the same as fff, I have tried both variants and they worked OK.
Regards,
Filip.
The f should behave the same as fff, I have tried both variants and they worked OK.
Regards,
Filip.
Re: problem of conversion
Hi,
I tried code in MikroC Pro.
With 'f' I get "'f' Identifier redefined", if 'f' is changed to 'ff' or 'fff' or something else code is compiled.
Best regards,
Peter
I tried code in MikroC Pro.
With 'f' I get "'f' Identifier redefined", if 'f' is changed to 'ff' or 'fff' or something else code is compiled.
Best regards,
Peter
- dejan.odabasic
- mikroElektronika team
- Posts: 2649
- Joined: 30 Apr 2012 14:20
Re: problem of conversion
Hello,
@tpetar
mikroC PRO for PIC will give your "...Identifier redefined", but mikroC PRO for PIC32 will not.
@brianho
Try changing your calculation like this:
Best regards.
@tpetar
mikroC PRO for PIC will give your "...Identifier redefined", but mikroC PRO for PIC32 will not.
@brianho
Try changing your calculation like this:
Code: Select all
int f, location1, location2;
float ans;
float heartrate;
f = abs (location1 - location2);
heartrate = ((f*5.0)/1000.0); // It will tell compiler to calculate with float numbers
// if your expression contains only integers calculation will be done on integers.
ans = 1/heartrate;
Re: problem of conversion
Thank You Dejan & Filip,
Best regards,
Peter
Best regards,
Peter