tag:blogger.com,1999:blog-36017112.post4705284044606741107..comments2014-10-23T16:56:41.744+01:00Comments on Featherweight Musings: Rust for C++ programmers - part 3: primitive types and operatorsNick Cameron.noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-36017112.post-55283224442038790192014-04-24T18:04:52.210+01:002014-04-24T18:04:52.210+01:00Don't forget that you can write 5_u8 (in fact,...Don't forget that you can write 5_u8 (in fact, you can put _ in arbitrary places within a number, e.g., 1_000_000_u32). I find that much more readable.Niko Matsakishttp://www.blogger.com/profile/17747970382445176700noreply@blogger.comtag:blogger.com,1999:blog-36017112.post-40823773343681881182014-04-23T13:22:26.646+01:002014-04-23T13:22:26.646+01:00In Rust, it is not called the modulo operator but ...In Rust, it is not called the modulo operator but the remainder operator. If you evaluate (-15) % 10 you will get -5. So that is a little bit awful, but we're probably stuck with it. One of the reasons it is like this is to be compatible with what C does, but I think most people expect it to behave like modulo in C, too, so the world is a little buggier as a result.<br /><br />https://github.com/mozilla/rust/pull/5990Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-36017112.post-5189118846391537072014-04-23T09:16:42.910+01:002014-04-23T09:16:42.910+01:00in C++, the integer division (and thus the modulo)...in C++, the integer division (and thus the modulo) with negative numbers is implementation-defined, with a preference to round towards 0 (eg, -15 \ 10 == -1 and 15 % 10 == -5); while some other languages (like Python) give the mathematical answer -2 and 5. In Rust, how the operator behaves?Anonymousnoreply@blogger.com