Am Fri, 21 Nov 2014 18:07:15 -0800 schrieb Walter Bright <[email protected]>:
> On 11/21/2014 1:33 PM, Marco Leise wrote: > > As someone using unsigned types all the time, all I need to > > keep in mind are two rules: > > > > 1) Overflow: > > > > uint number; > > … > > number = 10 * number + ch - '0'; > > > > It is handled with: > > if (number > uint.max / 10) > > if (number > uint.max - (ch - '0')) > > You're better off with core.checkedint here, as not only is it correct, but > (eventually) it will enable the compiler to optimize it to simply checking > the > carry flag. Ah right, I keep forgetting that module. By the way, are calls to core.checkedint inlined? Since they are in another module and not templated I'd think not. -- Marco
