The Hive Workshop
 Remember Me?
 Register FAQ Members List Calendar Mark Forums Read

 Graveyard Resources which were not approved are moved to this section.

 02-05-2011, 09:25 PM #1 (permalink) Nestharus Semi-Here   Join Date: Jul 2007 Posts: 6,326 [System] BigInt gone Last edited by Nestharus; 12-21-2013 at 08:35 PM.
Bribe
Keep it simple.

Code Moderator

Join Date: Sep 2009
Posts: 7,372

The Jass Optimizer breaks ExecuteFunc and UnitAlive, but the solution is to NOT use those natives. I'm sure that you will be adding a description later on, like usual, but stuff like this belongs in a scrapyard language like Perl:

Jass:
if (e[n[y]]) then
set n[y] = n[0]
set n[0] = y
set y = p[y]
set p[td] = y
set n[y] = td
else
set y = p[y]
endif
__________________
 My GUI Stuff My vJass Stuff Tutorials My PC Specs
Netbook: Atom N450 @1.67GHz, 2GB DDR2
Desktop: 2x Xeon 5160 @3GHz, Radeon HD 7850 2GB, 16GB ECC FBDIMM

Robbepop
Mapper - vJasser

Join Date: Mar 2008
Posts: 855
hiho,

how precise are these BigInts?
does it make sense to use them for numbers with a maximum of 500-200000?

Robbepop
__________________
 My Maps

Nestharus
Semi-Here

Join Date: Jul 2007
Posts: 6,326
100% precise.

This can handle up to around 8187 digits (in the base) or so if you only have one active number.

1234567 would be 7 digits if it were in b10
35,31,22 would be 3 digits for base 36

etc

Quote:
 does it make sense to use them for numbers with a maximum of 500-200000?
Not really ;D.

If doing this for save/load, see my new encryption algorithm that generates a key given a player name and encrypts the data with that key at the cost of 1 bit (1 binary digit, which is almost nothing).

Also keep in mind that you can merge up all of your numbers using this to minimize the size of your save/load code.

http://www.hiveworkshop.com/forums/t...yption-189120/

I'm also creating an Encoder that'll do binary shuffling on a BigInt.

Last edited by Nestharus; 02-09-2011 at 07:22 AM.

 02-07-2011, 11:57 PM #5 (permalink) Dr Super Good Imperial Good     Join Date: Jan 2005 Posts: 20,896 Surly it would be most efficent to store everything in native types... If you stored all parts in the lower 16 bits of the 32 bit integer type, you would have direct access to bits via simple division of a choosen part instead of having to run an expensive base conversion. Further more, if bitshifting is available (I forget if WC3 had it), you can directly get the overflow and have it ready for the next itteration. Standardizing the internal base also would allow the creation of efficent methods to add bigint to bigint or even (god help us) multiply bigint with bigint as well as remove all the code needed to support dynamic base size. This is no substitute for real BigInts... Real BigInts abuse specially created instructions that all computer processors have to allow them to be computed faster. For example, there is a overflow register available meaning that chunks can be as large as 64bits. JASS probaly has a shit compiler. Consider trying caching some indicies or common opperations into a local to see if a speed gain is given.
 02-08-2011, 01:26 AM #6 (permalink) Nestharus Semi-Here   Join Date: Jul 2007 Posts: 6,326 Actually, performing arithmetic on an integer would be much slower than looping through a list. Also, it doesn't have anything for shifting bits. All of the stuff can be done in this, and handling big bases would be faster than handling small bases because of the smaller amounts of iteration involved in the larger base operations ;D. Because this is stored digit by digit, it supports any base to any base conversion as the numbers are grouped properly when re added ^_^. And working with binary digits would be the slowest possible thing to do in JASS. The smaller the base, the slower.
Dr Super Good
Imperial Good

Join Date: Jan 2005
Posts: 20,896

Quote:
 Actually, performing arithmetic on an integer would be much slower than looping through a list.
Is the JASS compiler really that shit that loops (which usually involve integer arithimitic) are slower than integer arithimitic? To me that sounds a bit contradictory. Your processor can perform hundreds of millions of integer arithmitic opperations to memeory a second, billions to cache. Weather it is adding 1 to 1 or adding a million to a million, they take the same time as all 4 bytes for each number have to be loaded in any case.

I am afriad I seem to not be communicating my ideas properly.

Its a pitty you can not bitshift, that would make this system so much more efficent (as bitshift opperations are extreemly cheap compared to division or other calculatory instructions).

My sujestion was to make it use a hard coded base of 65536 as that would be half an integer allowing for up to half 65536 with muliplication (due to sign bits and no access to overflow registers) and fewer parts would mean fewer itteration needed (and as all parts are still the same word size, there is no extra computation cost). Further more, there would be no need to base convert to binary (expensive time wise as you said) since you could gain access to individual bits by division of powers of 2 and then modulation (again if bitshift and binary opperators were available, this would become insanly fast via masking flags).

Sigh, I guess JASS just plain sucks.

Bribe
Keep it simple.

Code Moderator

Join Date: Sep 2009
Posts: 7,372

JASS compiles into a beautiful game, providing an overall programming experience vastly superior than a "fast" programming language that does not have such satisfying output. How much more fun is it to run an algorithm through a function that you built rather than running it through something like a cell-phone calculator?
__________________
 My GUI Stuff My vJass Stuff Tutorials My PC Specs
Netbook: Atom N450 @1.67GHz, 2GB DDR2
Desktop: 2x Xeon 5160 @3GHz, Radeon HD 7850 2GB, 16GB ECC FBDIMM

 02-08-2011, 07:34 PM #9 (permalink) Nestharus Semi-Here   Join Date: Jul 2007 Posts: 6,326 I see, but that'd fail as then you couldn't really retrieve specific digits w/o math operations. If I wanted to loop through digit by digit and I wanted a base 10 number, I couldn't do it, or it'd be much, much slower. On another note, I am planning to change multiply to only take a single parameter and add a pow method ;D. method multiply takes integer value, integer exponent returns nothing to method multiply takes integer value returns nothing I will apply this change as soon as I finish up this set of hw. I only have like 1 hour left to finish half an assignment ;o. edit Removed pow and changed s2i to convertString. edit fixed add method (was broken) Last edited by Nestharus; 02-09-2011 at 06:21 AM.
Bribe
Keep it simple.

Code Moderator

Join Date: Sep 2009
Posts: 7,372

This has a lot of potential. When you're done mucking around with the API in the Base system this is good to go.
__________________
 My GUI Stuff My vJass Stuff Tutorials My PC Specs
Netbook: Atom N450 @1.67GHz, 2GB DDR2
Desktop: 2x Xeon 5160 @3GHz, Radeon HD 7850 2GB, 16GB ECC FBDIMM

Bribe
Keep it simple.

Code Moderator

Join Date: Sep 2009
Posts: 7,372

Alright, API on Base is secure, so this is in the field.
__________________
 My GUI Stuff My vJass Stuff Tutorials My PC Specs
Netbook: Atom N450 @1.67GHz, 2GB DDR2
Desktop: 2x Xeon 5160 @3GHz, Radeon HD 7850 2GB, 16GB ECC FBDIMM

 02-10-2011, 01:47 AM #12 (permalink) Nestharus Semi-Here   Join Date: Jul 2007 Posts: 6,326 Added the ever useful method toInt takes nothing returns integer edit fixed 2 bugs ^_^, working perfectly now. The 2 bugs had to do with untested methods (sh sh). The new toInt that was just added and the never used convertString, lol ; D. edit Optimized it a bit and changed how a lot of the loops operated. Do not worry as I tested every single method this time!! I also tested for leaks. add,divide,multiply,convertString,toString, forwards/backwards list continuity testing, leak testing, push,pop,enq,deq, toInt. It was all thoroughly tested this time >: O. However, if somehow I missed a bug, let me know ;D. Last edited by Nestharus; 02-10-2011 at 07:00 AM.
D4RK_G4ND4LF
Glorious Bacon of Light

Join Date: Feb 2009
Posts: 1,337

awesome!
I once did something similar in c++ but I had way less functions
how much slower are your bigints compared to casual ints?
__________________
 Inventory with unlimited slots [GUI] Jump-Parabolas Trackables in GUI

Bribe
Keep it simple.

Code Moderator

Join Date: Sep 2009
Posts: 7,372

About a million billion times slower ;)
__________________
 My GUI Stuff My vJass Stuff Tutorials My PC Specs
Netbook: Atom N450 @1.67GHz, 2GB DDR2
Desktop: 2x Xeon 5160 @3GHz, Radeon HD 7850 2GB, 16GB ECC FBDIMM

 Bookmarks