Welcome, Guest. Please login or register.

Author Topic: 64 bit integers in SAS/C  (Read 12913 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show all replies
    • http://totalchaoseng.dbv.pl/news.php
Re: 64 bit integers in SAS/C
« on: July 22, 2013, 01:32:27 AM »
Quote from: nOw2;741497

I'm not confident of patching the compiler with experimental code. SAS/C 6.5x is a restriction at the moment.

The patch was created by the ppl who wrote SASC.  It isn't like some random haxx0r made it. :)

Also, once you realize that all C compilers are experimental and have weird rare bugs then you realize that everything is ok.

There are at least 2 bugs in SASC 6.58.  Perhaps these have been fixed in v7.x?  Who knows?


Quote

I'm thinking of using two longs to hold the data, even if that makes calculations interesting. UtilityBase functions may be suitable for that, otherwise I'll roll my own.



Yep you are always allowed to create your own new datatypes.  You can code them in C or asm since SASC interfaces to asm routines easily.
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show all replies
    • http://totalchaoseng.dbv.pl/news.php
Re: 64 bit integers in SAS/C
« Reply #1 on: July 22, 2013, 08:33:13 AM »
Quote from: olsen;741551
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:


Quote

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.)
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show all replies
    • http://totalchaoseng.dbv.pl/news.php
Re: 64 bit integers in SAS/C
« Reply #2 on: July 22, 2013, 10:45:28 AM »
Quote from: olsen;741562

I'm not the one to judge, but it appears that some algorithms covered in great depth and detail by Knuth have aged better than others. Also, Knuth selected the algorithms which he covered both for their importance and didactic reasons, which means that the books are not necessarily a "directory" of algorithms and the problems which they solve. For that kind of book, I'd recommend "The algorithm design manual" by Steven Skiena.


I have the 2nd edition of that back from 2008.

Any other books I should arm myself with?

Would you happen to know of any books that you recommend that explain every single feature that was added to C99 with examples?  Or a good article on the internet?
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show all replies
    • http://totalchaoseng.dbv.pl/news.php
Re: 64 bit integers in SAS/C
« Reply #3 on: July 24, 2013, 01:11:06 PM »
@Now2

Is the Directory Opus 5 you are working on the same thing as:
Opus Magellan II (v5.8): 1998-11-01 ?

For some reason I had it in my head that v5.8 already had 64-bit math in it...
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA