[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [BUG]0/1=?
- From: Peter Cawley <lua@...>
- Date: Thu, 22 Jan 2009 18:21:48 +0000
It's purely the behaviour of the Microsoft C runtime with [s]printf functions.
This C code:
#include <stdio.h>
int main(int, char**)
{
double zero = 0.0;
double value = 1.0 / zero; // 1.0 / 0.0 causes a compile-time error
char buffer[32];
sprintf(buffer, "%f", value);
printf("0/1 = %s\n", buffer);
return 0;
}
Compiled using Visual Studio 2008, yields the following:
0/1 = 1.#INF00
On Thu, Jan 22, 2009 at 6:15 PM, Rob Kendrick <lua-l@nun.org.uk> wrote:
> On Thu, 22 Jan 2009 18:12:54 +0000
> Peter Cawley <lua@corsix.org> wrote:
>
>> It is the case under Windows when using MSVCRT:
>>
>> Microsoft Windows [Version 6.0.6001]
>> Copyright (c) 2006 Microsoft Corporation. All rights reserved.
>> C:\Users\Peter>lua
>> Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
>> > =tostring(1/0)
>> 1.#INF
>
> I'm trying to work out what causes this, and if it's intentional, why
> it is desirable. So far, I've failed.
> --
> B.
>