| Olathe | Twas my router. |
| zenspider | corundum: seen robbyonrails? |
| corundum | ...eh? robbyonrails was last seen 2 days, 22 hours, 55 minutes and 22 seconds ago, joining #ruby-lang |
| jnc | pre-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 |
| Olathe | jnc: What are you trying to accomplish ? |
| jnc | Olathe: 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 |
| Olathe | I mean with numbers. If you just want the last 32-bits, that works. |
| jnc | ohhh yeah 32-bits foobar += some_calculated_value & 0xffffffff was not working |
| Olathe | If you need it more general, num % 2**(number_of_bits) It wasn't ? |
| jnc | I don't really understand why it wasn't |
| Olathe | You mean foobar sometimes had more than 32 ? |
| jnc | well, 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 |
| Olathe | Oh. |
| jnc | (sorry, the pseduo code is right, forgot to remove my comment again on the 2nd version) |
| Olathe | Use varb += whatsit; varb &= 0xffffffff vara += varb; vara &= 0xffffffff |
| jnc | why use that instead of vara += varb & 0xffffffff |
| Olathe | What 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. |
| jnc | oh.... |
| Olathe | What a += b & 0xffffffff does is chop of leading bits of b, but not the sum. a = (a + b) & 0xffffffff might be cleaner, too. |
| orsonork | hello how do i write cases in ruby? forget it |
| jnc | case thing when condition end |