## Re: [Sdcc-user] single precision - computing sidereal time

 Re: [Sdcc-user] single precision - computing sidereal time From: Sebastien Lorquet - 2014-07-09 15:05:05 ```hello Maybe you can also use arbitrary precision fixed or floating point, using a bcd coding or not. example: using BCD, numbers from 0 to 99 with 14 decimal places uchar val1[16] = {0,6, 6,9,7,3,7,4,5,5,8,0,0,0,0,0}; //store 6.697374558 uchar vak2[16] = {0,0, 0,6,5,7,0,9,8,2,4,4,1,9,0,8}; //0.06570982441908 uchar dzero[16]; convert_from_unsigned_long(dzero, d0); multiply(dzero, dzero, val2); //compute 0.06570982441908 D0 into D0 add(dzero, dzero, val1); //compute 6.697374558 + 0.06570982441908 D etc etc In that case, you "just" have to reimplement the usual operations over your arbitrary precision type. there are lots of optims, like using packed BCD. PIC18 has opcodes to deal with BCD. You can also compute in "base 256" (binary) instead of bcd. If precision is enough, sinus may not need to be reimplemnted if you use conversions to/from float and the float sinus function. Also, libraries for this may already exist. BR, Sébastien Lorquet Le 09/07/2014 13:40, JuanPi a écrit : > Hi, > > If you realy are into numerics, you can emulate doubles using floats. > Here are some pointers > http://stackoverflow.com/questions/6769881/emulate-double-using-2-floats > At the endo of the day everythign is an integer, so you can always re > implement double precision (from your link you will need operators -, > +, * and function sin). > > The issue there is you are going to be doing a lot of bookkeeping (you > will be reinventing the wheel :D). > If you go this way I suggest you first test all you programs in a easy > to use language (Octave, Python, etc) using floats and integers. > > Of course it would be easy just to find a compiler with double support. > > Good luck. > > > On Wed, Jul 9, 2014 at 12:42 PM, Daniel Michalik wrote: >> Dear all, >> I'm trying to implement a conversion from solar (regular) time to >> sidereal time for astronomical purposes on a PIC16F1938. As far as I >> understand sdcc supports single precision only. I would like to ask for >> advice how to proceed. For the calculations necessary for the time >> conversion see http://aa.usno.navy.mil/faq/docs/GAST.php. >> I do not see how I could do this in single precision, but I'd love to >> hear some advice of people more experienced with microprocessor >> programming and sdcc. >> >> - Do I need to change to a different compiler than sdcc? >> - Can double precision floating point operations be emulated in a >> straight forward way within sdcc? >> - Is there a way to reformulate the conversion to be correct with single >> precision calculations? >> >> Kind regards, >> Daniel >> >> ------------------------------------------------------------------------------ >> Open source business process management suite built on Java and Eclipse >> Turn processes into business applications with Bonita BPM Community Edition >> Quickly connect people, data, and systems into organized workflows >> Winner of BOSSIE, CODIE, OW2 and Gartner awards >> http://p.sf.net/sfu/Bonitasoft >> _______________________________________________ >> Sdcc-user mailing list >> Sdcc-user@... >> https://lists.sourceforge.net/lists/listinfo/sdcc-user > > > ```

 [Sdcc-user] single precision - computing sidereal time From: Daniel Michalik - 2014-07-09 11:09:48 ```Dear all, I'm trying to implement a conversion from solar (regular) time to sidereal time for astronomical purposes on a PIC16F1938. As far as I understand sdcc supports single precision only. I would like to ask for advice how to proceed. For the calculations necessary for the time conversion see http://aa.usno.navy.mil/faq/docs/GAST.php. I do not see how I could do this in single precision, but I'd love to hear some advice of people more experienced with microprocessor programming and sdcc. - Do I need to change to a different compiler than sdcc? - Can double precision floating point operations be emulated in a straight forward way within sdcc? - Is there a way to reformulate the conversion to be correct with single precision calculations? Kind regards, Daniel ```
 Re: [Sdcc-user] single precision - computing sidereal time From: JuanPi - 2014-07-09 11:40:40 ```Hi, If you realy are into numerics, you can emulate doubles using floats. Here are some pointers http://stackoverflow.com/questions/6769881/emulate-double-using-2-floats At the endo of the day everythign is an integer, so you can always re implement double precision (from your link you will need operators -, +, * and function sin). The issue there is you are going to be doing a lot of bookkeeping (you will be reinventing the wheel :D). If you go this way I suggest you first test all you programs in a easy to use language (Octave, Python, etc) using floats and integers. Of course it would be easy just to find a compiler with double support. Good luck. On Wed, Jul 9, 2014 at 12:42 PM, Daniel Michalik wrote: > Dear all, > I'm trying to implement a conversion from solar (regular) time to > sidereal time for astronomical purposes on a PIC16F1938. As far as I > understand sdcc supports single precision only. I would like to ask for > advice how to proceed. For the calculations necessary for the time > conversion see http://aa.usno.navy.mil/faq/docs/GAST.php. > I do not see how I could do this in single precision, but I'd love to > hear some advice of people more experienced with microprocessor > programming and sdcc. > > - Do I need to change to a different compiler than sdcc? > - Can double precision floating point operations be emulated in a > straight forward way within sdcc? > - Is there a way to reformulate the conversion to be correct with single > precision calculations? > > Kind regards, > Daniel > > ------------------------------------------------------------------------------ > Open source business process management suite built on Java and Eclipse > Turn processes into business applications with Bonita BPM Community Edition > Quickly connect people, data, and systems into organized workflows > Winner of BOSSIE, CODIE, OW2 and Gartner awards > http://p.sf.net/sfu/Bonitasoft > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@... > https://lists.sourceforge.net/lists/listinfo/sdcc-user -- Juan Pablo Carbajal Engagement manager http://www.dwengo.org Follow us on: Facebook: http://facebook.com/dwengo Twitter: @dwengo of http://twitter.com/dwengo Youtube: http://www.youtube.com/user/Dwengovzw Google RISE project: http://goo.gl/BD540 Chat: #dwengo in irc.freenode.net ```
 Re: [Sdcc-user] single precision - computing sidereal time From: Sebastien Lorquet - 2014-07-09 15:05:05 ```hello Maybe you can also use arbitrary precision fixed or floating point, using a bcd coding or not. example: using BCD, numbers from 0 to 99 with 14 decimal places uchar val1[16] = {0,6, 6,9,7,3,7,4,5,5,8,0,0,0,0,0}; //store 6.697374558 uchar vak2[16] = {0,0, 0,6,5,7,0,9,8,2,4,4,1,9,0,8}; //0.06570982441908 uchar dzero[16]; convert_from_unsigned_long(dzero, d0); multiply(dzero, dzero, val2); //compute 0.06570982441908 D0 into D0 add(dzero, dzero, val1); //compute 6.697374558 + 0.06570982441908 D etc etc In that case, you "just" have to reimplement the usual operations over your arbitrary precision type. there are lots of optims, like using packed BCD. PIC18 has opcodes to deal with BCD. You can also compute in "base 256" (binary) instead of bcd. If precision is enough, sinus may not need to be reimplemnted if you use conversions to/from float and the float sinus function. Also, libraries for this may already exist. BR, Sébastien Lorquet Le 09/07/2014 13:40, JuanPi a écrit : > Hi, > > If you realy are into numerics, you can emulate doubles using floats. > Here are some pointers > http://stackoverflow.com/questions/6769881/emulate-double-using-2-floats > At the endo of the day everythign is an integer, so you can always re > implement double precision (from your link you will need operators -, > +, * and function sin). > > The issue there is you are going to be doing a lot of bookkeeping (you > will be reinventing the wheel :D). > If you go this way I suggest you first test all you programs in a easy > to use language (Octave, Python, etc) using floats and integers. > > Of course it would be easy just to find a compiler with double support. > > Good luck. > > > On Wed, Jul 9, 2014 at 12:42 PM, Daniel Michalik wrote: >> Dear all, >> I'm trying to implement a conversion from solar (regular) time to >> sidereal time for astronomical purposes on a PIC16F1938. As far as I >> understand sdcc supports single precision only. I would like to ask for >> advice how to proceed. For the calculations necessary for the time >> conversion see http://aa.usno.navy.mil/faq/docs/GAST.php. >> I do not see how I could do this in single precision, but I'd love to >> hear some advice of people more experienced with microprocessor >> programming and sdcc. >> >> - Do I need to change to a different compiler than sdcc? >> - Can double precision floating point operations be emulated in a >> straight forward way within sdcc? >> - Is there a way to reformulate the conversion to be correct with single >> precision calculations? >> >> Kind regards, >> Daniel >> >> ------------------------------------------------------------------------------ >> Open source business process management suite built on Java and Eclipse >> Turn processes into business applications with Bonita BPM Community Edition >> Quickly connect people, data, and systems into organized workflows >> Winner of BOSSIE, CODIE, OW2 and Gartner awards >> http://p.sf.net/sfu/Bonitasoft >> _______________________________________________ >> Sdcc-user mailing list >> Sdcc-user@... >> https://lists.sourceforge.net/lists/listinfo/sdcc-user > > > ```