Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Log formula
#31
Yeah, unsigned integer arrays are better than strings for long numbers. I'll tell you why.

With every character added (1 byte long), the number that you can have is 10 times bigger, as every character is a new figure in a base-10 number (this is very similar to "BCD").

Using unsigned integer arrays, your number is just like you appended all your integers binarily. That is, if you array has two integers, your resulting number would be in the range of a long, and so forth. Wich every integer added (2 bytes long), the number that you can have is 65536 times bigger.

To make a comparison, using 4 bytes you can represent a number up to 9999 using strings and up to 4Gigs (more than 4,000,000,000) using unsigned integer arrays.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#32
NATHAN:
What are unsigned interger arrays? You say it's like BCD. Do you mean the 6 bit Binary Coded Decimal which became the 8 bit EBCDIC? Or do you mean Packed Decimal notation which uses 4 bits for each decimal digit? But, packed decimal does have a sign in the rightmost nybl.

Enlighten me.
*****
Reply
#33
Nope. Imagine a single unsigned array that has an unsigned integer in each array cell. Imagine a 4 elments array. The thing is dealing with that array as a whole number, just appending a number at the end of the latter.

With 1 element, as it is an unsigned integer, you could represent from 0 to 65535. With 2 elements, making an imaginary number appending the two array cells in binary, you would have a number from 0 to 65536*65536-1 (this is what is done to build a long: append two ints). With three array cells, you would have a number from 0 to 65536^3-1. And so forth.

If array[0] = 1001110001011111 and array[1] = 1100101000011100, the library acts as it was a big integer 11001010000111001001110001011111.

All ancient big integer math libraries are done that way.

I entered the BCD stuff just to clarify things, but I messed everything up Tongue. What I was comparing to BCD was using strings as numbers like oracle is doing. But BCD is using 4 bits to represent 10 numbers and oracle is using 8 bits, so it is even worse memory-wise.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#34
The condensensed point is that you lose a HELL of a lot of ease in programming this (AND computational TIME AND SPACE!!) if you cannot use unsigned integers (integers in the range 0 to 65535)... since you can easily determine whether or not A^B is negative or not... just carry the sign of A.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#35
NATHAN,
I get the idea, but I was under the impression that QB or QuickBasic cannot manipulate unsigned integers. Is this being programmed in some other language?

AGA, I didn't understand you at all. Sorry.
*****
Reply
#36
Moneo: In real languages where you have unsigned stuff, yes. C, Pascal, assembly... In QB you can find turnarounds. Numbers are just bits. Signed/unsinged, as well as integer/float/fixed point is just a matter of interpretation. Using INT to STRING functions and reverse (CVI and stuff) you could perform some nice stuff.

Agamemnus: I haven't understood you either.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#37
Nathan, I wish you wouldn't use the term "real languages" when referring to languages other than Basic. I have done many, many "real" applications as recently as last year that were written in QuickBasic. Over the course of the last 20 years I have used various versions of Basic for the following:
* Bank alarm monitoring systems.
* A system for connecting a bank to NACHA (National Clearing House Association) for cash concentration, saving millions of dollars in float.
* Manufacturing system with bills of material, parts explosions and implosions, etc.
* Bills Purchase banking system that handled transactions for $70 million dollars a day.
* Multiuser Human Resource system.
* Utility programs for a LAN with 6 file servers conected to a mainframe and serving 100 users.
* A complete ERP system consisting of 1500 realtime programs running in 5 countries.
* A herd management system and an inventory system for a major dairy farm with a herd of over 1500 cows.

Have you ever heard of PIckBasic or UniBasic? The ERP system which I mentioned above is written in this language under a multivalued database. There are 3 million users of this language. It's considered an old, legacy system, but it's still out there.

So please don't be negative when you refer to Basic. Lot's of people make negative remarks about Cobol as well, forgetting that there are more Cobol programs in trhe world than of any other language.

Gee I'm glad I got that off my chest! Big Grin
Reply
#38
I meant QB, not BASIC.

QB is not suited for math stuff, or to do really efficient stuff, because of the way it is conceived. Being a purely high level language it doesn't support very basic stuff as pointers (or references) or unsigned data types, which makes it really not suited to build complex ADTs. Also, being a DOS language, it surely has nothing to do in current internet world (well, it could do some neat CGI stuff if correctly configured, but there are better alternatives).

I've found that QB for fun is great. QB as a hobby is greater. QB is challenging, and interesting, but I would not use QB in a real project just because it is a big hassle. If I want easy coding, I go directly to 32 bits C. It is easier, you don't have a single memory problem, you have real data types, you can build ADTs... Doing a simple offscreen buffer in QB is a big trouble. Building a simple binary tree in QB is a party of walkarounds and problems, problems, problems. Memory limitations, stack limitations, code size limitations...

I am completely aware about your success using QB and another BASIC dialects, and I sincerely congratulate you. But, speaking of QB, out of a pure DOS computer it has nothing to do, and, sadly, DOS computers are disappearing. As I told recently to Jark, if his goal was teaching fractal and raytracing to people, it was a pitty that only 1 out of 10 people were able to run his software just for a single reason: It was written in QB.

Maybe 10 years ago writing a real application in QB was factible, but I am talking about nowadays and the future. Maybe a small farm can perform its economic and administrative stuff in a 486 running a neat bunch of QB proggies, but as concepts like domotic, internet and wireless communications emmerge and grow, I've found that QB has nothing to do in this new world just for one simple reason: It runs in an obsolete OS that doesn't support all this stuff.

Maybe if QB worked natively in Linux and Windows XP I would change my mind, of course. But it still would miss tons of features (remember that old thread?).

But to break a lance (as we say in Spain) for QB, beginning coding in such a limited language makes you think better when you travel to the comfy world of C/C++/Java. You end optimizing even when you don't need to. I've found that many MSVC trained programmers forgot how to optimize, 'cause they made their first "hello world" program in a 2 Ghz computer Tongue

Cheers Wink
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#39
Nathan,
Sad to say, you're right. Thanks for your comprehensive and sympathetic response. I think that the key issue or coup de grace (puntilla) in the final death of all DOS-based versions of any Basic, is as you said "DOS computers are disappearing". The same may happen at some future date to cars that run on gasoline.

We old-timers tend to hang on to things that we enjoyed and had success with in the past. I'll probably drive my gasoline car until the last gas station closes. :wink:
Reply
#40
Hey, I'm also an old-timer, but I have to mentalize myself and leave the old stuff to my self enjoyment. I still like playing 80's games Wink This may not look "very old", but I was a kid then Wink I still can't find the same enjoyment in any modern game as I found in the 8 bits oldies.

Anyhow, we QB and DOS programmers can be very useful in places where limited economy is a real issue. Last year, my father was teaching a 10 years old girl whose family was somewhat poor. Me and a friend put together a fully featured 486 with Windows 95 and MS Office, and now she has a computer to make her stuff and assignments. It costed around $30.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)