why compiler try use my sqrt not std.math?

KnightMare black80 at bk.ru
Wed May 8 08:16:27 UTC 2019


// ============= test5.d ==============
import std.stdio, std.conv, std.bigint, std.math, std.algorithm;

ulong sqrt( ulong n ) { return cast( ulong )real( n ).sqrt; }
ulong sqrt1( ulong n ) { return cast( ulong )real( n ).sqrt.ceil; 
}

void main() { }
// ============= EOF test5.d ==============

and result is:
test5.d(5): Error: std.math.ceil called with argument types 
(ulong) matches both:
C:\programz\D\ldc2\bin\..\import\std\math.d(4869):     
std.math.ceil(real x)
and:
C:\programz\D\ldc2\bin\..\import\std\math.d(4982):     
std.math.ceil(float x)

prog compiles ok when I comment my ulong sqrt( ulong )

IMO about sqrt1 (I tried cast(real)n instead real(n) too with 
same result)
real(n).sqrt should to use real std.math.sqrt(real) that returns 
real. so ceil should be used real std.math.ceil(real). and after 
that only cast to ulong.

what happened here?


More information about the Digitalmars-d mailing list