Thread overview
issue with inf from exp function
Mar 07, 2018
Matt Gamble
Mar 07, 2018
Alex
Mar 07, 2018
Matt Gamble
Mar 07, 2018
Marc
Mar 07, 2018
Marc
Mar 07, 2018
Matt Gamble
Mar 07, 2018
Marc
Mar 07, 2018
Matt Gamble
Mar 07, 2018
Matt Gamble
March 07, 2018
I don't understand why I'm getting an 'inf' by raising E to a real number, e^^710.0L. See below.

import std.stdio;
import std.math;

unittest
{
	writefln("ln(largest double) = %s", log(double.max)); // 709.783
	writefln("e^710 = %s", exp(710.0));// inf, makes sense

	writefln("ln(largest real) = %s", log(real.max)); // 11356.6
	real t = 710.0;
	writefln("e^710 = %s", exp(t)); //why is this inf???
}

Any help would be greatly appreciated. I have functions in an actual program that are giving me a headache due to this issue.
March 07, 2018
On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
> I don't understand why I'm getting an 'inf' by raising E to a real number, e^^710.0L. See below.
>
> import std.stdio;
> import std.math;
>
> unittest
> {
> 	writefln("ln(largest double) = %s", log(double.max)); // 709.783
> 	writefln("e^710 = %s", exp(710.0));// inf, makes sense
>
> 	writefln("ln(largest real) = %s", log(real.max)); // 11356.6
> 	real t = 710.0;
> 	writefln("e^710 = %s", exp(t)); //why is this inf???
> }
>
> Any help would be greatly appreciated. I have functions in an actual program that are giving me a headache due to this issue.

works for me as expected.

ln(largest double) = 709.783
e^710 = inf
ln(largest real) = 11356.5
e^710 = 2.23399e+308
March 07, 2018
On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
> On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
>> I don't understand why I'm getting an 'inf' by raising E to a real number, e^^710.0L. See below.
>>
>> import std.stdio;
>> import std.math;
>>
>> unittest
>> {
>> 	writefln("ln(largest double) = %s", log(double.max)); // 709.783
>> 	writefln("e^710 = %s", exp(710.0));// inf, makes sense
>>
>> 	writefln("ln(largest real) = %s", log(real.max)); // 11356.6
>> 	real t = 710.0;
>> 	writefln("e^710 = %s", exp(t)); //why is this inf???
>> }
>>
>> Any help would be greatly appreciated. I have functions in an actual program that are giving me a headache due to this issue.
>
> works for me as expected.
>
> ln(largest double) = 709.783
> e^710 = inf
> ln(largest real) = 11356.5
> e^710 = 2.23399e+308

Really? Is it my system?
I'm running windows 10, with an intel Core i7-4650, 64bit operating system
I compiled with -m64 -g -unittest -main
March 07, 2018
On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
> On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
>> I don't understand why I'm getting an 'inf' by raising E to a real number, e^^710.0L. See below.
>>
>> import std.stdio;
>> import std.math;
>>
>> unittest
>> {
>> 	writefln("ln(largest double) = %s", log(double.max)); // 709.783
>> 	writefln("e^710 = %s", exp(710.0));// inf, makes sense
>>
>> 	writefln("ln(largest real) = %s", log(real.max)); // 11356.6
>> 	real t = 710.0;
>> 	writefln("e^710 = %s", exp(t)); //why is this inf???
>> }
>>
>> Any help would be greatly appreciated. I have functions in an actual program that are giving me a headache due to this issue.
>
> works for me as expected.
>
> ln(largest double) = 709.783
> e^710 = inf
> ln(largest real) = 11356.5
> e^710 = 2.23399e+308

it works for me too.

https://imgur.com/bLGTv1l

March 07, 2018
On Wednesday, 7 March 2018 at 16:06:26 UTC, Matt Gamble wrote:
> On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
>> On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
>>> [...]
>>
>> works for me as expected.
>>
>> ln(largest double) = 709.783
>> e^710 = inf
>> ln(largest real) = 11356.5
>> e^710 = 2.23399e+308
>
> Really? Is it my system?
> I'm running windows 10, with an intel Core i7-4650, 64bit operating system
> I compiled with -m64 -g -unittest -main

Did notice you were using -m64 flag before. Well, now I used -m64 the same code doesn't work as expected. I also got inf.
March 07, 2018
On Wednesday, 7 March 2018 at 16:10:15 UTC, Marc wrote:
> On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
>> On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
>>> [...]
>>
>> works for me as expected.
>>
>> ln(largest double) = 709.783
>> e^710 = inf
>> ln(largest real) = 11356.5
>> e^710 = 2.23399e+308
>
> it works for me too.
>
> https://imgur.com/bLGTv1l

Wow, Now I'm really confused, I'm using DMD v2.076.1. Any thoughts I why I'm getting this result?
March 07, 2018
On Wednesday, 7 March 2018 at 16:12:28 UTC, Matt Gamble wrote:
> On Wednesday, 7 March 2018 at 16:10:15 UTC, Marc wrote:
>> On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
>>> On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
>>>> [...]
>>>
>>> works for me as expected.
>>>
>>> ln(largest double) = 709.783
>>> e^710 = inf
>>> ln(largest real) = 11356.5
>>> e^710 = 2.23399e+308
>>
>> it works for me too.
>>
>> https://imgur.com/bLGTv1l
>
> Wow, Now I'm really confused, I'm using DMD v2.076.1. Any thoughts I why I'm getting this result?

See my previous post. It's something related to generating 64bit code.

March 07, 2018
On Wednesday, 7 March 2018 at 16:12:28 UTC, Matt Gamble wrote:
> On Wednesday, 7 March 2018 at 16:10:15 UTC, Marc wrote:
>> On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
>>> On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
>>>> [...]
>>>
>>> works for me as expected.
>>>
>>> ln(largest double) = 709.783
>>> e^710 = inf
>>> ln(largest real) = 11356.5
>>> e^710 = 2.23399e+308
>>
>> it works for me too.
>>
>> https://imgur.com/bLGTv1l
>
> Wow, Now I'm really confused, I'm using DMD v2.076.1. Any thoughts I why I'm getting this result?

Yes if I switch to 32bit, it works for me now. Is this a bug?
March 07, 2018
On 3/7/18 11:19 AM, Matt Gamble wrote:
> On Wednesday, 7 March 2018 at 16:12:28 UTC, Matt Gamble wrote:
>> On Wednesday, 7 March 2018 at 16:10:15 UTC, Marc wrote:
>>> On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
>>>> On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
>>>>> [...]
>>>>
>>>> works for me as expected.
>>>>
>>>> ln(largest double) = 709.783
>>>> e^710 = inf
>>>> ln(largest real) = 11356.5
>>>> e^710 = 2.23399e+308
>>>
>>> it works for me too.
>>>
>>> https://imgur.com/bLGTv1l
>>
>> Wow, Now I'm really confused, I'm using DMD v2.076.1. Any thoughts I why I'm getting this result?
> 
> Yes if I switch to 32bit, it works for me now. Is this a bug?

Looks like it. The core.stdc.math module looks very cryptic, but appears to do some weird things via exp on real.

-Steve
March 07, 2018
On Wednesday, 7 March 2018 at 16:40:04 UTC, Steven Schveighoffer wrote:
> On 3/7/18 11:19 AM, Matt Gamble wrote:
>> On Wednesday, 7 March 2018 at 16:12:28 UTC, Matt Gamble wrote:
>>> On Wednesday, 7 March 2018 at 16:10:15 UTC, Marc wrote:
>>>> On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
>>>>> [...]
>>>>
>>>> it works for me too.
>>>>
>>>> https://imgur.com/bLGTv1l
>>>
>>> Wow, Now I'm really confused, I'm using DMD v2.076.1. Any thoughts I why I'm getting this result?
>> 
>> Yes if I switch to 32bit, it works for me now. Is this a bug?
>
> Looks like it. The core.stdc.math module looks very cryptic, but appears to do some weird things via exp on real.
>
> -Steve

Thanks. I submitted as a bug. https://issues.dlang.org/show_bug.cgi?id=18570