Re: 64bit math ,, CChris ?
- Posted by CChris <christian.cuvier at a?riculture.gouv.fr> Jun 04, 2008
- 593 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 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