Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The rust code for rounding down is given as

    let new_ptr = new_ptr & !(align - 1);
But I don't see rdx decremented before being negated and AND'ed with rax, in the assembly. What am I missing?


It's being converted into `-align` which is equivalent under twos compliment


I don't follow. Are you saying `new_ptr & -align` is equivalent to `new_ptr & !(align - 1)`?

Edit: I get it now. My brain was interpreting NEG as NOT for some reason.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: