Thread overview
sqrt ?
Oct 09, 2004
Asaf Karagila
Oct 09, 2004
Sjoerd van Leent
Oct 09, 2004
Sjoerd van Leent
Oct 09, 2004
Tyro
Oct 09, 2004
Asaf Karagila
Oct 09, 2004
Tyro
October 09, 2004
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.


October 09, 2004
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
October 09, 2004
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
October 09, 2004
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
October 09, 2004
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
October 09, 2004
"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