Code:

PUB ln(x) | integer, bchange, fraction ' calculates natural logarithm*10000 of positive integer
' from 1 to $FFFFFFFF using Log Table
integer := >|x - 1 ' calculating integer by the leading byte position
bchange := x <- (11- integer) ' the address of fraction by proportional extrapolation
fraction := word[$C000 + (bchange &= %11111111111)*2] ' finding the fraction
result := ((integer*6931 + fraction * 6931 / $10000) + (integer*6932 + fraction * 6932 / $10000))/2
' combining results and multiplication by ln2
' two additons to get 0.69315 without overriding

## Bookmarks