[Issue 14569] BigInt is not compatible with the type of immutable (char) and has a problem when converting from a type immutable(char)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Sep 15 18:39:30 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=14569

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |simen.kjaras at gmail.com
         Resolution|---                         |INVALID

--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
Your expectations of what e.to!BigInt should do does not square up with what's
being done for int and uint, and you even point that out in the bug report
itself - e.to!int gives a different result from what you expect. It could be
argued that BigInt should have the same behavior as does int and uint, but
having a different behavior for BigInt would break the principle of least
astonishment, and thus be a Bad Thingâ„¢. 

Judging from the report, you're implementing a sum of digits. If s in your case
was "123", you probably expect sum1, sum2, sum3 and sum4 to be 6, as that would
be the sum of digits.  As sum2 and sum3 shows, you instead get a sum of the
values of the unicode code points making up the string.

--


More information about the Digitalmars-d-bugs mailing list