www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - sqrt ?

reply "Asaf Karagila" <kas1 netvision.net.il> writes:
Hi,
i'm pretty new to D, i was never too much a C/C++ programmer, so i don't 
have too much knowledge from that side,
i've got one simple question, how do i use a sqrt() function in D ?
at first, i figured, if its in math.h, i would use 'import std.c.math' and 
just call out sqrt(),
but it didn't work. seeing how i don't have anyone using D that i know, i 
came here..

thanks in advance,

Asaf. 
Oct 09 2004
parent reply Sjoerd van Leent <svanleent wanadoo.nl> writes:
Asaf Karagila wrote:
 Hi,
 i'm pretty new to D, i was never too much a C/C++ programmer, so i don't 
 have too much knowledge from that side,
 i've got one simple question, how do i use a sqrt() function in D ?
 at first, i figured, if its in math.h, i would use 'import std.c.math' and 
 just call out sqrt(),
 but it didn't work. seeing how i don't have anyone using D that i know, i 
 came here..
 
 thanks in advance,
 
 Asaf. 
 
 
For sqrt() you should use the std.intrinsic module. This module has the sqrt() function build in. Before going any further, it may be wise to read the Phobos page at the place a little bit. http://www.digitalmars.com/d/phobos.html Regards, Sjoerd
Oct 09 2004
next sibling parent reply Sjoerd van Leent <svanleent wanadoo.nl> writes:
Sjoerd van Leent wrote:
 Asaf Karagila wrote:
 
 Hi,
 i'm pretty new to D, i was never too much a C/C++ programmer, so i 
 don't have too much knowledge from that side,
 i've got one simple question, how do i use a sqrt() function in D ?
 at first, i figured, if its in math.h, i would use 'import std.c.math' 
 and just call out sqrt(),
 but it didn't work. seeing how i don't have anyone using D that i 
 know, i came here..

 thanks in advance,

 Asaf.
For sqrt() you should use the std.intrinsic module. This module has the sqrt() function build in. Before going any further, it may be wise to read the Phobos page at the place a little bit. http://www.digitalmars.com/d/phobos.html Regards, Sjoerd
BTW, std.math also includes the sqrt() function. Regards, Sjoerd
Oct 09 2004
parent reply Tyro <ridimz_at yahoo.dot.com> writes:
Sjoerd van Leent wrote:
 Sjoerd van Leent wrote:
 
 Asaf Karagila wrote:

 Hi,
 i'm pretty new to D, i was never too much a C/C++ programmer, so i 
 don't have too much knowledge from that side,
 i've got one simple question, how do i use a sqrt() function in D ?
 at first, i figured, if its in math.h, i would use 'import 
 std.c.math' and just call out sqrt(),
 but it didn't work. seeing how i don't have anyone using D that i 
 know, i came here..

 thanks in advance,

 Asaf.
For sqrt() you should use the std.intrinsic module. This module has the sqrt() function build in. Before going any further, it may be wise to read the Phobos page at the place a little bit. http://www.digitalmars.com/d/phobos.html Regards, Sjoerd
BTW, std.math also includes the sqrt() function.
However, there are conflicting defininitions of sqrt() in std.math. [i.e. creal sqrt(creal) conflicts with float sqrt(float)] which I think is the problem Asaf ran into.
 Regards,
 Sjoerd
Oct 09 2004
parent "Asaf Karagila" <kas1 netvision.net.il> writes:
"Tyro" <ridimz_at yahoo.dot.com> wrote in message
news:ck8d1n$d7a$1 digitaldaemon.com...
 Sjoerd van Leent wrote:
 Sjoerd van Leent wrote:

 Asaf Karagila wrote:

 Hi,
 i'm pretty new to D, i was never too much a C/C++ programmer, so i
 don't have too much knowledge from that side,
 i've got one simple question, how do i use a sqrt() function in D ?
 at first, i figured, if its in math.h, i would use 'import std.c.math'
 and just call out sqrt(),
 but it didn't work. seeing how i don't have anyone using D that i know,
 i came here..

 thanks in advance,

 Asaf.
For sqrt() you should use the std.intrinsic module. This module has the sqrt() function build in. Before going any further, it may be wise to read the Phobos page at the place a little bit. http://www.digitalmars.com/d/phobos.html Regards, Sjoerd
BTW, std.math also includes the sqrt() function.
However, there are conflicting defininitions of sqrt() in std.math. [i.e. creal sqrt(creal) conflicts with float sqrt(float)] which I think is the problem Asaf ran into.
 Regards,
 Sjoerd
i kind of solved my problem before i saw the replies, i used the std.math sqrt() one, which is using real, my code (a stupid isprime() function) is now ok, i think.. thanks for the help though.. Cheers, Asaf
Oct 09 2004
prev sibling parent Tyro <ridimz_at yahoo.dot.com> writes:
Sjoerd van Leent wrote:
 Asaf Karagila wrote:
 
 Hi,
 i'm pretty new to D, i was never too much a C/C++ programmer, so i 
 don't have too much knowledge from that side,
 i've got one simple question, how do i use a sqrt() function in D ?
 at first, i figured, if its in math.h, i would use 'import std.c.math' 
 and just call out sqrt(),
 but it didn't work. seeing how i don't have anyone using D that i 
 know, i came here..

 thanks in advance,

 Asaf.
For sqrt() you should use the std.intrinsic module. This module has the sqrt() function build in. Before going any further, it may be wise to read the Phobos page at the place a little bit. http://www.digitalmars.com/d/phobos.html
There is no sqrt() function in the std.intrinsic module. The documentation is incorrect.
 Regards,
 Sjoerd
Oct 09 2004