Another Dang code problem....
Trouble wth the Fp.Pow cmd in Float32Full
Here is the code (Bold/Red at the problem):
pub convert2Radians(quad,sPtr) : rads | i,fractPartPtr,c,dd,mm,mmmm,NM,miles,feet,degs,p
'' sPtr is a pointer to a latitude/longitude string in ddmm.mmmm or dddmm.mmmm format
'' returns the equivalent value in floating point radians (use fs.FloatToString(rads) to display value)
····
··· bytefill(@buf,0,20)································ 'clear buffer
··· bytemove(@buf,sPtr,strsize(sPtr))·················· 'Make a copy to mess with
··
··· i := 0
·····
··· repeat············································· 'Locate the '.' (decimal point)·
····· c:=buf[noparse][[/noparse] i++ ]
··· until c == "."
·······
··· buf[noparse][[/noparse] --i ] := 0···································· 'split into 2 strings by replacing '.' with null
···
··· fractPartPtr := @buf[noparse][[/noparse] i+1 ]························ 'Fractional part is what was after the '.'
··· i-=2··············································· 'back up 2 bytes to get the minutes
··· bytemove(@minPart[noparse][[/noparse] 0 ],@buf[noparse][[/noparse] i ],2)················ 'copy the mm part
··· minPart[noparse][[/noparse] 2 ] := 0·································· 'null terminate the mm part
···
··· dd·· := Format.atoi(@buf)/100······················ 'Remove mm part (divide by 100) and convert to number
··· mm·· := Format.atoi(@minPart)
··· mmmm := Format.atoi(fractPartPtr)
··
··· i := strsize(fractPartPtr)
·······
··· i := ff.ffloat(i)
····
··· p := fp.pow(10.0,i)··· 'Code·hangs Here!!!!!!!
··· dd·· := fp.ffloat(dd)
··· mm·· := fp.ffloat(mm)······························ 'Convert to floating point number
··· mmmm := fp.fdiv(fp.ffloat(mmmm),p)
····
··· degs := fp.fadd(fp.fdiv(fp.fadd(mm, mmmm),60.0),dd) 'Convert to decimal degrees
··· if strcomp(quad, string("S"))
····· degs := fp.fneg(degs)
··· if strcomp(quad, string("W"))
····· degs := fp.fneg(degs)
··· rads := fp.radians(degs)··························· 'Convert to radians
···
··· return rads
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Was it pin 11 or 26?· Hmmm....··I think the smell of smoke tells the whole story.· Must be 26.
Michael King
Application Engineer
R&D
Digital Technology Group
Here is the code (Bold/Red at the problem):
pub convert2Radians(quad,sPtr) : rads | i,fractPartPtr,c,dd,mm,mmmm,NM,miles,feet,degs,p
'' sPtr is a pointer to a latitude/longitude string in ddmm.mmmm or dddmm.mmmm format
'' returns the equivalent value in floating point radians (use fs.FloatToString(rads) to display value)
····
··· bytefill(@buf,0,20)································ 'clear buffer
··· bytemove(@buf,sPtr,strsize(sPtr))·················· 'Make a copy to mess with
··
··· i := 0
·····
··· repeat············································· 'Locate the '.' (decimal point)·
····· c:=buf[noparse][[/noparse] i++ ]
··· until c == "."
·······
··· buf[noparse][[/noparse] --i ] := 0···································· 'split into 2 strings by replacing '.' with null
···
··· fractPartPtr := @buf[noparse][[/noparse] i+1 ]························ 'Fractional part is what was after the '.'
··· i-=2··············································· 'back up 2 bytes to get the minutes
··· bytemove(@minPart[noparse][[/noparse] 0 ],@buf[noparse][[/noparse] i ],2)················ 'copy the mm part
··· minPart[noparse][[/noparse] 2 ] := 0·································· 'null terminate the mm part
···
··· dd·· := Format.atoi(@buf)/100······················ 'Remove mm part (divide by 100) and convert to number
··· mm·· := Format.atoi(@minPart)
··· mmmm := Format.atoi(fractPartPtr)
··
··· i := strsize(fractPartPtr)
·······
··· i := ff.ffloat(i)
····
··· p := fp.pow(10.0,i)··· 'Code·hangs Here!!!!!!!
··· dd·· := fp.ffloat(dd)
··· mm·· := fp.ffloat(mm)······························ 'Convert to floating point number
··· mmmm := fp.fdiv(fp.ffloat(mmmm),p)
····
··· degs := fp.fadd(fp.fdiv(fp.fadd(mm, mmmm),60.0),dd) 'Convert to decimal degrees
··· if strcomp(quad, string("S"))
····· degs := fp.fneg(degs)
··· if strcomp(quad, string("W"))
····· degs := fp.fneg(degs)
··· rads := fp.radians(degs)··························· 'Convert to radians
···
··· return rads
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Was it pin 11 or 26?· Hmmm....··I think the smell of smoke tells the whole story.· Must be 26.
Michael King
Application Engineer
R&D
Digital Technology Group
Comments
b) Have you printed out the integer then float values of i prior to the call to fpower call?
c) Would the function fp.Exp10(i) be as appropriate ?
Cheers!
PR
Then you'd use "powers[noparse][[/noparse] i ]" where "i" is a value from 0 to 7.
Good idea Mike! I updated my version too.