Welcome, Guest. Please login or register.

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

Description:

0 Members and 1 Guest are viewing this topic.

Offline olsen

Re: 64 bit integers in SAS/C
« Reply #14 from previous page: July 22, 2013, 09:48:16 AM »
Quote from: ChaosLord;741553
Yeah!!!!!!!!!!!!!!!!!!!!!!  Olsen saves the day!!!!!!  :banana:


Many of the problems which are still relevant were solved (or at least chipped away at) some 5-10 years ago. It's just getting harder to find the solutions. My own contribution is (correctly) filed away in the comm/tcp section of Aminet, but who'd look there for it?

It's challenging to build a good knowledge base for Amiga programming :(

Quote

I have the 2nd edition of that book from 1981.  Is that good enough?


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.

Quote

Have any new algorithms been invented since 1981?


Of course :)  For example, probabilistic algorithms (e.g. skip lists) were not invented until the late 1980'ies.
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: 64 bit integers in SAS/C
« Reply #15 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 olsen

Re: 64 bit integers in SAS/C
« Reply #16 on: July 22, 2013, 11:18:13 AM »
Quote from: ChaosLord;741565
I have the 2nd edition of that back from 2008.

Any other books I should arm myself with?


Arm against what, exactly? ;)

Now that we have the Internet (things were so much rougher in the early 2000's and before), the importance of having the right selection of books in your personal library has declined somewhat. If you follow the trail of breadcrumbs, you'll invariably find a good, comprehensive collection of algorithm documentation and implementation. Just start on the page for "Quicksort" in Wikipedia and look through the footnotes and links at the bottom of the article's page.

The one exception concerning books I would make is Steven Skiena's book ("The algorithm design manual") which I already mentioned. The first half of the book covers algorithms in general (what are these things, how do they work, how do you build them, how can you tell when there's no scalable/optimal solution for a problem), and while this part is already great, the second half is really crackers.

The second half (modestly labeled "Resources") is a catalog of algorithms, categorized by problem domain. This doesn't sound much, but each section contains a general description of what problems fall into each class and can be solved algorithmically, and then gives a list of hints that allow you to pick the best likely solution for each problem.

This helps to overcome the big obstacle you'll always have when you're looking for a good or better approach to solving a problem with an algorithm: finding one which does the job, and making an informed decision when choosing between alternatives. For example, when you have to sort small numbers of integers, what kind of algorithm will you pick? Will you use heaps, for example, or trust in a recursive algorithm? Which circumstances surrounding your need for a matching algorithm would favour heapsort over shellsort, or even merge sort?

Quote

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?


I can recommend "C - A reference manual" (5th edition) by Guy Steele & Sam Harbison (well, it's mainly by Guy Steele). It makes for a great reference manual, too, so the title is actually spot on and not just for show ;)
 

Offline nOw2Topic starter

  • Full Member
  • ***
  • Join Date: Jul 2002
  • Posts: 194
    • Show only replies by nOw2
Re: 64 bit integers in SAS/C
« Reply #17 on: July 24, 2013, 12:37:38 PM »
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).


Just a quick reply to say thanks as that is exactly what I was looking for. I didn't know where to start but that gets me going in the right direction.

I now have Directory Opus 5 reporting disk sizes correctly. Next job, calculations for files and directories.
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: 64 bit integers in SAS/C
« Reply #18 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
 

Offline nOw2Topic starter

  • Full Member
  • ***
  • Join Date: Jul 2002
  • Posts: 194
    • Show only replies by nOw2
Re: 64 bit integers in SAS/C
« Reply #19 on: July 24, 2013, 06:25:47 PM »
Yes, or 5.82 Magellan 2 at least. It was open sourced through a bounty. And no, it doesn't support 64bit maths on sizes :)
 

Offline olsen

Re: 64 bit integers in SAS/C
« Reply #20 on: July 25, 2013, 03:27:35 PM »
Quote from: nOw2;741977
Just a quick reply to say thanks as that is exactly what I was looking for. I didn't know where to start but that gets me going in the right direction.

I now have Directory Opus 5 reporting disk sizes correctly. Next job, calculations for files and directories.


Cool, so writing the stuff in the first place and putting it on Aminet for others to find it useful did turn out to be a good idea. Glad to have been of some help :)
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1149
    • Show only replies by Thorham
Re: 64 bit integers in SAS/C
« Reply #21 on: May 06, 2017, 10:57:27 PM »
VERY late, but here's disk size in bytes for greater than 32 bits using only 32 bit integers:

Code: [Select]
   unsigned int low;
    unsigned int high;

    low = info->id_NumBlocks % 100000;
    high = info->id_NumBlocks / 100000;

    low *= info->id_BytesPerBlock;
    high *= info->id_BytesPerBlock;

    high += low / 100000;
    low = low % 100000;

    printf("Size: %d%d bytes.\n", high, low);
 

guest11527

  • Guest
Re: 64 bit integers in SAS/C
« Reply #22 on: May 06, 2017, 11:11:04 PM »
Reviving this old thread....  Back then, I had (and still have) a somewhat icky approach at 64 bit math with SAS/C which required a bit wrestling with the compiler. The trick is to compile with math=ieee, then use a typedef  typedef double long_long;  and instead of the usual arithmetic operators, you called (in my case assembler, but could also be C) stups "addll(op1,op2)" and so on of the signature  long_long addll(op1,op2);  The trick is here that SAS/C packs the "seemingly floating point numbers" into register pairs (as by math=ieee) and you could store and move them around as you like as SAS/C does itself not care what the registers represent. The only troublesome part was the arithmetic which had to be spelled out by individual function calls instead of the usual operators (which would have called mathieeedoubbas, which you did not want).  Now, if you used the SAS/C C++ compiler, you could get away even with that and write it in the usual arithmetics with operator overloading...  It's a neat trick, though you still did not have a "printf()" for a long long. Sorry, long_long.
 

Offline billt

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 910
    • Show only replies by billt
    • http://www.billtoner.net
Re: 64 bit integers in SAS/C
« Reply #23 on: May 07, 2017, 03:15:33 PM »
How dows one get sasc 7.01? I only remember 6.5something as the max...
Bill T
All Glory to the Hypnotoad!
 

Offline psxphill

Re: 64 bit integers in SAS/C
« Reply #24 on: May 07, 2017, 05:07:52 PM »
Quote from: billt;825465
How dows one get sasc 7.01? I only remember 6.5something as the max...


These two are on aminet, no idea what the difference is between them

http://aminet.net/package/dev/c/expsascxx.lha
http://aminet.net/package/dev/c/expsascxx_old.lha
 

Offline psxphill

Re: 64 bit integers in SAS/C
« Reply #25 on: May 07, 2017, 05:12:37 PM »
Quote from: Thorham;825449


Code: [Select]

    printf("Size: %d%d bytes.\n", high, low);


The printf is wrong, because low isn't zero filled.

you'd need something like:
Code: [Select]

    if (high)
        printf("Size: %d%05d bytes.\n", high, low);
    else
        printf("Size: %d bytes.\n", low);
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1149
    • Show only replies by Thorham
Re: 64 bit integers in SAS/C
« Reply #26 on: May 07, 2017, 10:39:45 PM »
Quote from: psxphill;825467
The printf is wrong, because low isn't zero filled.
You're right, thanks. Don't know how I missed that.