I have done this in C many years back. However, you need to use double precision floating point numbers to get accurate results. PicBasic code? I doubt it as Picbasic does not support this data type.