Have a look at the http://aminet.net/comm/tcp/SendRawDisk.lha utility which I wrote a while ago (full source code included). It includes both 64 bit arithmetic code written in portable 'C', as well a complete set of functions for accessing "large disks" (covering both NSD/TD64, with auto-detection of some sort which handles both sets transparently).
Yeah!!!!!!!!!!!!!!!!!!!!!! Olsen saves the day!!!!!! :banana:
The purpose of this utility was to make it easier to transfer disk images from my Amiga to UAE. But if you're after the arithmetic functions, please by my guest
Multiplication and addition are rather straightforward. The division algorithm is a tricky one, though. Would you believe that there are several different division algorithms, some more readable than others?
If you're in dire need of arithmetic algorithms, I would hesitate to recommend Knuth's "The Art of Computer Programming: Seminumerical algorithms" (chapter 4). You have to master both the language in which the implementations are written, and make something useful out of the copious notes which accompany them. Many programmers work extra hard on solving problems on their own, rather than looking them up in the Knuth
I have the 2nd edition of that book from 1981. Is that good enough?
Have any new algorithms been invented since 1981?
@nOw2
I have not tested SASC v7.x yet. I plan to test it sometime in a couple of weeks and I will compile giant piles of source codes thru it to see if it works or not.
I predict that 64-bit integers (long long) will work perfectly in SASC v7.x
I predict that any bugs will be in a few random routines in the C library where they forgot to add 64-bit support or somehow messed it up. These library functions will be functions I have never used and never will use or I use them but will never use them with 64-bit integers. For what you are trying to accomplish I think you will be safe and it would take you years to find a bug.
It took me something like 6 years to find a bug in SASC 6.58. And I was using the compiler every single day and night and compiling giant programs with it. Its not like I was just compiling a tiny 2000 line program on the weekends or something. I was really banging SASC hard. The bug I found can only be triggered by linking asm code (which gets inlined) that takes floating point parameters. Although I have been doing some hardcore studying of Advanced C books lately and I have found that C wants to always promote all types to either into or double when calling functions. So maybe I could have worked around the problem by using Doubles instead of Floats? (The forced promotion is not supposed to happen when you use a concrete datatype.)
p.s. Feel free to post any discoveries or problems that you find both here and at
www.AmigaCoding.de which is an entire giant forum specifically for Programming Amigas and is kinda like the reincarnation of UtilityBase (R.I.P.)