• mindbleach@sh.itjust.works
    link
    fedilink
    arrow-up
    3
    ·
    10 months ago

    I do some 8-bit coding and only last month realized logarithms allow dirt-cheap multiplication and division. I had never used them in a context where floating-point wasn’t readily available. Took a function I’d painstakingly optimized in 6502 assembly, requiring only two hundred cycles, and instantly replaced it with sixty cycles of sloppy C. More assembly got it down to about thirty-five… and more accurate than before. All from doing exp[ log[ n ] - log[ d ] ].

    Still pull my hair out doing anything with tangents. I understand it conceptually. I know how it goddamn well ought to work. But it is somehow the fiddliest goddamn thing to handle, despite being basically friggin’ linear for the first forty-five degrees. Which is why my code also now cheats by doing a (dirt cheap!) division and pretending that’s an octant angle.