1. 64bit math ,, CChris ?
- Posted by Kat <KAT12 at coosah?.n?t> Jun 04, 2008
- 640 views
So i did this:
word w1, w2, w3, w4, w5 w1 = atom_to_word(16777216) w2 = atom_to_word(65536) w3 = mul_word(w1,w2) w4 = atom_to_word(12) w5 = add_word(w3,w4) ? w5
And this happened: C:\euphoria\64bit math\kattest.1.exw:10 type_check failure, w3 is {{0,0,0,0,0,0,0},{0,0,0,0,256,0,0},1} How is that possible? i defined w3 as a word, and the function returns a word, right? Kat
2. Re: 64bit math ,, CChris ?
- Posted by CChris <christian.cuvier at agriculture?g?uv.fr> Jun 04, 2008
- 630 views
Kat wrote: > > > So i did this: > > }}} <eucode> > word w1, w2, w3, w4, w5 > > w1 = atom_to_word(16777216) > w2 = atom_to_word(65536) > w3 = mul_word(w1,w2) > w4 = atom_to_word(12) > w5 = add_word(w3,w4) > > ? w5 > </eucode> {{{ > > And this happened: > > C:\euphoria\64bit math\kattest.1.exw:10 > type_check failure, w3 is {{0,0,0,0,0,0,0},{0,0,0,0,256,0,0},1} > > > How is that possible? i defined w3 as a word, and the function returns a word, > right? > > Kat Looks like a bug, will check tonight (it's 2:35pm here) from home, where I have this code available. Thanks for the report. CChris
3. Re: 64bit math ,, CChris ?
- Posted by Bob Thompson <getter at fa??mail.co.uk> Jun 04, 2008
- 636 views
- Last edited Jun 05, 2008
Kat wrote: > w1 = atom_to_word(16777216) Hi Kat, Is this about reducing memory demand, i.e. converting words (average 8 x 4 = 32 bytes) to 16 bytes, or have I totally lost it and it turns out that it's a Win32Lib thing? You can convert them to integers (4 bytes) with look up tables. Regards, Bob
4. Re: 64bit math ,, CChris ?
- Posted by Kat <KAT12 at coo?ahs.n?t> Jun 04, 2008
- 640 views
- Last edited Jun 05, 2008
Bob Thompson wrote: > > Kat wrote: > > > w1 = atom_to_word(16777216) > > Hi Kat, > > Is this about reducing memory demand, i.e. converting words > (average 8 x 4 = 32 bytes) to 16 bytes, or have I totally lost it and > it turns out that it's a Win32Lib thing? No, it's about 64bit math, like i said. CChris has one of the bigmath libs in the user contribs, and i have been going over each in antici pation of getting goto(next line). :label "next line" Eu 31bit signed integers are quite limited in the modern world of 700gigabyte drives and 10gigabyte files. Using 64bit integers (uint or ulong or udwords, etc) is one thing, using them well requires a whole new lib (or 2 or 3) apart from Eu's built-ins. This is separate from 8bit or 16bit strings. A whole other animal. Kat
5. Re: 64bit math ,, CChris ?
- Posted by CChris <christian.cuvier at a?riculture.gouv.fr> Jun 04, 2008
- 642 views
- Last edited Jun 05, 2008
Kat wrote: > > > So i did this: > > }}} <eucode> > word w1, w2, w3, w4, w5 > > w1 = atom_to_word(16777216) > w2 = atom_to_word(65536) > w3 = mul_word(w1,w2) > w4 = atom_to_word(12) > w5 = add_word(w3,w4) > > ? w5 > </eucode> {{{ > > And this happened: > > C:\euphoria\64bit math\kattest.1.exw:10 > type_check failure, w3 is {{0,0,0,0,0,0,0},{0,0,0,0,256,0,0},1} > > > How is that possible? i defined w3 as a word, and the function returns a word, > right? > > Kat The bug is in the example. Doc say: global function mul_word(word w1,word w2) -- Author: Christian Cuvier -- Created: September 8th,2005 -- Updated: N/A -- Platform: GEN -- Description: Returns the complete product of two words. -- Takes: The words to multiply ogether. -- Returns: A sequence {high word, low word, sign of product}. However I found a real bug, in integers_to word() this time: insert w[ZERO]=0 after
if p=0 then return w end if
So you have to define some sequence s and then s = mul_words(w1,w2) w3=s[2] Again, thanks. CChris