Thread overview
[Issue 7078] New: BigInt.toInt returns a long
Dec 08, 2011
Don
Feb 23, 2012
Don
December 08, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7078

           Summary: BigInt.toInt returns a long
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2011-12-07 17:38:20 PST ---
Despite what the ddoc of BigInt.toInt() says, it returns a long. I suggest to
change toInt() to really return an int:


/// Returns the value of this BigInt as a long,
/// or +- long.max if outside the representable range.
long toLong() pure const
{
    return (sign ? -1 : 1) *
      (data.ulongLength() == 1 && (data.peekUlong(0) <= cast(ulong)(long.max))
      ? cast(long)(data.peekUlong(0))
      : long.max);
}
/// Returns the value of this BigInt as an int,
/// or +- int.max if outside the representable range.
long toInt() pure const
{
    return (sign ? -1 : 1) *
      (data.uintLength() == 1 && (data.peekUint(0) <= cast(uint)(int.max))
      ? cast(int)(data.peekUint(0))
      : int.max);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 08, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7078


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-12-08 00:26:45 PST ---
https://github.com/D-Programming-Language/phobos/pull/358

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7078


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2012-02-23 14:30:23 PST ---
Fixed some time ago. https://github.com/D-Programming-Language/phobos/commit/d619dd513f2f5f7ab2639c34118f03c1672f4485

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------