1. 64bit math ,, CChris ?

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

new topic     » topic index » view message » categorize

2. Re: 64bit math ,, CChris ?

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: 64bit math ,, CChris ?

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: 64bit math ,, CChris ?

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: 64bit math ,, CChris ?

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu