How do I convert from Int to Float and Float to Int, I want to do some calculations on values read from Analogue to Digital converter?. I can't see any function to do this in the calculation help file.
Regards Gary
Float to Int
Moderator: Benj
-
- Posts: 38
- Joined: Fri Nov 07, 2008 12:57 pm
- Has thanked: 7 times
- Been thanked: 4 times
- Steve
- Matrix Staff
- Posts: 3431
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
Re: Float to Int
"float2int" and "int2float" are the appropriate functions. These don't seem to be in the help file, but it should be obvious how to use them. They are listed in the "functions..." window in the calculation icon window.
-
- Posts: 38
- Joined: Fri Nov 07, 2008 12:57 pm
- Has thanked: 7 times
- Been thanked: 4 times
Re: Float to Int
Thanks
Is there a Round to zero function?, I can use.
I trying to display the result of a calculation to the lcd
Cft=459.59
Mft=1.7276
ans=(A2d value - Cft)/Mft
I am doing this at the moment to try and get around it.
Adcft = int2float(Adcint)
Temp1ft = fsub(Adcft, Cft)
Xft = fdiv(Temp1ft, Mft)
Wholeint = float2int(Xft)
Wholeft = int2float(Wholeint)
Decft = fmod(Xft, Wholeft)
Decint = float2int(Decft)
lcd printnumber Wholeint
lcd printAscii "."
lcd printnumber Decint
eg 34.59
Regards Gary
Is there a Round to zero function?, I can use.
I trying to display the result of a calculation to the lcd
Cft=459.59
Mft=1.7276
ans=(A2d value - Cft)/Mft
I am doing this at the moment to try and get around it.
Adcft = int2float(Adcint)
Temp1ft = fsub(Adcft, Cft)
Xft = fdiv(Temp1ft, Mft)
Wholeint = float2int(Xft)
Wholeft = int2float(Wholeint)
Decft = fmod(Xft, Wholeft)
Decint = float2int(Decft)
lcd printnumber Wholeint
lcd printAscii "."
lcd printnumber Decint
eg 34.59
Regards Gary