www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4455] New: Taking the sqrt of an integer shouldn't require an explicit cast.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4455

           Summary: Taking the sqrt of an integer shouldn't require an
                    explicit cast.
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com



This one's been around for ages, but has just now started bothering me enough
to file a bug report:

import std.math;

void main() {
    uint num = 1;
    auto ans = sqrt(num);
}

Error:
test.d(5): Error: function std.math.sqrt called with argument types:
    ((uint))
matches both:
    std.math.sqrt(float x)
and:
    std.math.sqrt(real x)

I guess the solution is to make long and ulong overloads that forward to
std.math.sqrt(real x).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 13 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4455


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



Partially unrelated: an efficient D compiler can desire to implement the sqrt
with SSE instructions like SQRTSS RSQRTSS SQRTPS and RSQRTPS, that have floats
or doubles in input or output. So I think a double sqrt(double) too can be
useful, to avoid the useless argument passing of 10-12-16 bytes (necessary for
an argument of type real) for the computation of sqrt on a double.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 13 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4455


David Simcha <dsimcha yahoo.com> changed:

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



Fixed SVN.

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