#ruby-lang - Wed 16 May 2007 between 00:05 and 01:08



OlatheTwas my router.
zenspidercorundum: seen robbyonrails?
corundum...eh?
robbyonrails was last seen 2 days, 22 hours, 55 minutes and 22 seconds ago, joining #ruby-lang
jncpre-result = aeccbfaada2a7da0e182, class = Bignum
Test passed (7da0e182).
holy damn, 20 byte number
for addition, how many bytes do I need to render a correct 32-bit result?
i.e. at the end of all this I do 0xffffffff & 0xaeccbfaada2a7da0e182
Olathejnc: What are you trying to accomplish ?
jncOlathe: implement AccurateRip algo to verify checksums of arbitrary data points in a rip of an audio CD
Olathe: it's working now, at acceptable speed ... I've settled on a place to mask off bits that aren't needed
OlatheI mean with numbers. If you just want the last 32-bits, that works.
jncohhh
yeah 32-bits
foobar += some_calculated_value & 0xffffffff
was not working
OlatheIf you need it more general, num % 2**(number_of_bits)
It wasn't ?
jncI don't really understand why it wasn't
OlatheYou mean foobar sometimes had more than 32 ?
jncwell, there's like vara = 0; LOOPA { varb = 0; LOOPB { varb += some_calculation & 0xffffffff }; vara += varb };
that was resulting in some incorrect value of vara
well, there's like vara = 0; LOOPA { varb = 0; LOOPB { varb += some_calculation }; vara += varb & 0xffffffff };
that worked though
OlatheOh.
jnc(sorry, the pseduo code is right, forgot to remove my comment again on the 2nd version)
OlatheUse varb += whatsit; varb &= 0xffffffff
vara += varb; vara &= 0xffffffff
jncwhy use that instead of vara += varb & 0xffffffff
OlatheWhat can happen is, if you have whatsit += addend & 0xffffffff
If whatsit and the last 32 bits of addend are really big 32-bit numbers, they add to a 33-bit number
So, you want to add them together, and only after adding chop off leading bits.
jncoh....
OlatheWhat a += b & 0xffffffff does is chop of leading bits of b, but not the sum.
a = (a + b) & 0xffffffff might be cleaner, too.
orsonorkhello
how do i write cases in ruby?
forget it
jnccase thing when condition end

Page: 2 9 16 23 30 37 

IrcArchive