30 May 2014, 17:00 | #21 |
Moderator
Join Date: Jan 2003
Location: ...
Age: 52
Posts: 1,838
|
I don't think anyone used SAS/C with its own editor...
I certainly did not. Used CygnusED+Opus and compiled with SAS+Devpac. You can build a very reasonable environment around these keeping the best bits of each. The last version of SAS/C was doing very decent optimisations for its time. Obviously, these days you'd be way better of with a recent version of GCC or LLVM - and just use your favourite editor etc. |
01 June 2014, 01:56 | #22 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
Code:
if (size>=102400) { size=(size*100+512)/1024/100; unit="TB"; } |
01 June 2014, 15:42 | #23 | |
Registered User
Join Date: Feb 2014
Location: Germany
Posts: 261
|
Quote:
If you still don't know what's wrong, i suggest you to attend some basic math lessons at school. It's obvious you didn't understand the code Thomas has provided. USE a calculator to check your #*-ยง$% equation. And a final warning, if you stick with 32 bit integer, you will be unable to query the numbers of blocks (or segments) from any drive bigger than 2 gigs tera if blocksize is 512 byte. I'm out. Last edited by BigFan; 01 June 2014 at 20:29. Reason: giga to tera |
|
01 June 2014, 17:21 | #24 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,987
|
|
01 June 2014, 20:27 | #25 |
Registered User
Join Date: Feb 2014
Location: Germany
Posts: 261
|
|
01 June 2014, 20:53 | #26 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,987
|
And you probably won't see drives bigger than 2 TB on AmigaOS anyway because of the same reason: both dos.library/Info() and HD_SCSICMD/Read Capacity use 32bit numbers for block size and number of blocks. If block size is 512, 2 TB is the limit. Whether block sizes other than 512 work on AmigaOS has not been proven yet.
|
02 June 2014, 00:56 | #27 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
NumBlocks=2147483647 (1TB)
size=(NumBlocks/bpm*100+512)/1024; = 102,400 >=102400 yes size=(size*100+512)/1024/100; = 100 (TB) sprintf(BTUBuffer,"%lu.%02lu %s",size/100,size % 100,unit); = 1.00 TB NumBlocks=3221225470 (1.5TB) size=(NumBlocks/bpm*100+512)/1024; = 153,600 >=102400 yes size=(size*100+512)/1024/100; = 150 (TB) sprintf(BTUBuffer,"%lu.%02lu %s",size/100,size % 100,unit); = 1.50 TB I know I will never see a TB drive on OS3.9, but if someone uses it on OS4, they all seem to have 1TB or 2TB drives. |
02 June 2014, 11:44 | #28 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,987
|
Wrong test. Try NumBlocks = 3326452170. This is 1.549 TB which should round up to 1.55 TB. But your code displays 1.54 TB.
Here is a test driver which lets you enter block size and terabyte value: Code:
int main (int argc,char **argv) { char buffer[20]; unsigned long b; unsigned long n; double f; if (argc != 3) { printf ("invalid args\n"); return (20); } b = atol(argv[1]); f = atof(argv[2]); #define KB ((double)1024) f *= KB * KB * KB * KB; n = f / (double)b; printf ("%lu * %lu = %s\n",b,n,nice_size(buffer,b,n)); return (0); } Please try to understand what the expression (x + 512) / 1024 does, especially why + 512 is in there. Then think about why (y + 512) / 102400 does not do the same. |
03 June 2014, 20:20 | #29 |
Registered User
Join Date: Sep 2013
Location: Bettendorf, IA, USA
Age: 52
Posts: 204
|
OK....now we are all on the same page. Did some more testing, the numbers were working out simply because they are so large and were rounding close to the actual values. I was also testing with Google and another site that rounds to 3 places, so it always looked correct, but yes, I was off.
On to other parts of the project............. |
28 October 2014, 15:09 | #30 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,753
|
Very late, but... if it's for 68020+, just use 64bit divu/divs (inline some asm).
|
28 October 2014, 18:59 | #31 |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
That would be straight forward if the 68020 had integer 64/64=64 and 64*64=64 but it has 64/32=32 (with 32 rem) and 32*32=64. It could be done with inlined assembler 68020 instructions but requires care as multiple instructions and multiple datatypes are needed (tricky to return a 64 bit int when the compiler doesn't support this datatype). It's easier and safer to use a compiler that supports 64 bit (long long) ints. The executable using inlined assembler may be faster for someone that is knowledgeable but there usually isn't much 64 bit math.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Out of this Little Big World - Little Big Planet | s2325 | Retrogaming General Discussion | 3 | 05 April 2015 05:09 |
Big Big Boxes | BinoX | Hardware pics | 6 | 27 July 2006 02:35 |
Towers (Warning, long shot and long post) | Drake1009 | Looking for a game name ? | 2 | 13 May 2005 00:11 |
BIG BIG BIG WINUAE CRASH (with .dmp file included) | The Rom Alien | support.WinUAE | 4 | 31 August 2004 20:26 |
A very long, LONG shot... | staticgerbil | Coders. General | 0 | 13 April 2003 11:18 |
|
|