On 30/6/04 14:47, Hal Daume III wrote:
i'm looking for an accurate way to take the log of a very large integer, for example:
let x :: Integer = 130142727215188116061276556022688196621810140343691778718485630367238262325689 845541676397895906730024965277394371574303273329260262483498476173923323279461 919361195473572028476105814689924661111323670085360089179896892077534449168518 590692259602654391532136757777452291231593014452347270238624064599385936823085 594101937144705866411597403257188107243160465138552039367484067881179355426659 501377394743411557958891296796968015047325823672783086783214986710043714270547 671666903964025267795520158937805183611280026836733145529671590438773283635061 353921824995082955541839719790928834530340719498354530821282866299962327922291 308021419628714011758281176918848669320822757025713685194594340820628167255555 828946025686701689606333414064007570808358186629749461083454555486484630638301 4549439540479675828018496049574066533167553894586573246931377586176000
this # is approximately 10^850.
Hal, Based on the old manual way of doing this, I would first obtain the log10 value. This is easiest if you can convert the number to a string: - if the original number is an integer, the string length gives you the exponent, which in log10 forms the integer part of the result - then take the first few digits of the string, concat '0.' in front, convert to a double, and obtain the log10 of that, which forms the decimal part of the result. And given the log10, if you want loge or ln then all you have to do is multiply by loge(10), if I remember correctly. Howard. Dr Howard Oakley The Works columnist for MacUser magazine (UK) http://www.macuser.co.uk/