Jump to page: 1 2
Thread overview
Remainder wat
Mar 04, 2012
Adam D. Ruppe
Mar 04, 2012
deadalnix
Mar 04, 2012
Adam D. Ruppe
Mar 04, 2012
James Miller
Mar 04, 2012
deadalnix
Mar 04, 2012
Adam D. Ruppe
Mar 04, 2012
Timon Gehr
Mar 04, 2012
deadalnix
Mar 04, 2012
Adam D. Ruppe
Mar 05, 2012
deadalnix
Mar 05, 2012
Martin Nowak
Mar 04, 2012
Timon Gehr
Mar 04, 2012
deadalnix
Mar 05, 2012
Martin Nowak
Mar 05, 2012
James Miller
March 04, 2012
Hi,

$ cat test.d
import std.conv;

void main()
{
    uint x = to!uint("1") % 0u;
}
$ rdmd test.d
Floating point exception


-- 
- Alex
March 04, 2012
What's weird about this? Processors raise
an exception when you ask them to divide by
zero.

Perhaps "Floating point exception" is a weird
message to give, but that's something the operating
system does; it is the default signal handler's
message.


I guess it is also a little weird that it didn't
say "test9.d(2): Error: divide by 0".. the to!uint
seems to trick dmd into not realizing what you are
saying. It catches the literal 1 % 0.

March 04, 2012
Le 04/03/2012 20:20, Adam D. Ruppe a écrit :
> What's weird about this? Processors raise
> an exception when you ask them to divide by
> zero.
>
> Perhaps "Floating point exception" is a weird
> message to give, but that's something the operating
> system does; it is the default signal handler's
> message.
>

That is the problem. No floating point operation is involved here. And if you replace to!uint("1") by just plain old 1, you don't get the same message, which is very inconsistent, and counterintuitive.
March 04, 2012
On Sunday, 4 March 2012 at 21:07:50 UTC, deadalnix wrote:
> No floating point operation is involved here.

It is a Linux issue, not a D one.

Try doing the same thing in C.
March 04, 2012
On 5 March 2012 10:11, Adam D. Ruppe <destructionator@gmail.com> wrote:
> On Sunday, 4 March 2012 at 21:07:50 UTC, deadalnix wrote:
>>
>> No floating point operation is involved here.
>
>

Division is probably handled by the floating-point section of the processor, so that's probably why the error says that. However i agree that it is not helpful.

--
James Miller
March 04, 2012
Le 04/03/2012 22:11, Adam D. Ruppe a écrit :
> On Sunday, 4 March 2012 at 21:07:50 UTC, deadalnix wrote:
>> No floating point operation is involved here.
>
> It is a Linux issue, not a D one.
>
> Try doing the same thing in C.

OK, now read the other half of the post.
March 04, 2012
On Sunday, 4 March 2012 at 21:52:15 UTC, deadalnix wrote:
> OK, now read the other half of the post.

Try reading the second half of my first post.
March 04, 2012
On 03/04/2012 10:58 PM, deadalnix wrote:
> Le 04/03/2012 22:11, Adam D. Ruppe a écrit :
>> On Sunday, 4 March 2012 at 21:07:50 UTC, deadalnix wrote:
>>> No floating point operation is involved here.
>>
>> It is a Linux issue, not a D one.
>>
>> Try doing the same thing in C.
>
> OK, now read the other half of the post.

I bet he did, but settled to responding to the part that was explicitly marked as being 'the problem'.
March 04, 2012
On 03/04/2012 10:59 PM, Adam D. Ruppe wrote:
> On Sunday, 4 March 2012 at 21:52:15 UTC, deadalnix wrote:
>> OK, now read the other half of the post.
>
> Try reading the second half of my first post.

Presumably it lacks drama (compare "a little weird" to "very inconsistent, and counterintuitive"), and therefore is not worth reading?


March 04, 2012
Le 04/03/2012 22:59, Timon Gehr a écrit :
> On 03/04/2012 10:58 PM, deadalnix wrote:
>> Le 04/03/2012 22:11, Adam D. Ruppe a écrit :
>>> On Sunday, 4 March 2012 at 21:07:50 UTC, deadalnix wrote:
>>>> No floating point operation is involved here.
>>>
>>> It is a Linux issue, not a D one.
>>>
>>> Try doing the same thing in C.
>>
>> OK, now read the other half of the post.
>
> I bet he did, but settled to responding to the part that was explicitly
> marked as being 'the problem'.

You'll find 2 problems, not one.

Problem one is the floating point reference, which is a problem when no floating point is involved. This is the counterintuitive part.

Problem two is the inconsistency of behavior. Sometime a divide error is triggered and some other a floating point error. This is the inconsistent part.
« First   ‹ Prev
1 2