POV-Ray : Newsgroups : povray.beta-test : No error message for array element nr. -1 Server Time
29 Jul 2024 14:18:39 EDT (-0400)
  No error message for array element nr. -1 (Message 1 to 3 of 3)  
From: Tor Olav Kristensen
Subject: No error message for array element nr. -1
Date: 8 May 2002 19:59:06
Message: <3CD9BB0E.61B2992@hotmail.com>
I just discovered that RC4 for Windows does not issue an
error message if one tries to access array element nr. -1

Here's the code I tried:


#declare A = array[1] { 0 }

// No error messages
#declare N = A[-1]; 
#declare A[-1] = 0;

// "Parse Error: Negative subscript"
#declare N = A[-2]; 
#declare A[-2] = 0;


If this is not old news, then can anyone please confirm this ?


Tor Olav


Post a reply to this message

From:
Subject: Re: No error message for array element nr. -1
Date: 9 May 2002 02:37:22
Message: <v66kdu0ou58og7rain2ur778mlhqgcd2bh@4ax.com>
On Thu, 09 May 2002 01:55:58 +0200, Tor Olav Kristensen
<tor### [at] hotmailcom> wrote:
> I just discovered that RC4 for Windows does not issue an
> error message if one tries to access array element nr. -1
>
> Here's the code I tried:
>
> #declare A = array[1] { 0 }
>
> // No error messages
> #declare N = A[-1]; 
> #declare A[-1] = 0;

I can confirm however I wonder if it could be ... floating point accuracy.
What rounding is performed when float is converted to integer ? Truncation
towards zero ? Could it be that -1 is internally something like -0.99999999999
and after truncation it is valid value 0 ? If yes then possible fix is to
check sign of the float before conversion to int.

POV 3.5 RC4 icl on WinNT Sp 6 PII 233 with 128 MB

ABX


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: No error message for array element nr. -1
Date: 9 May 2002 04:32:03
Message: <3cda3403@news.povray.org>

Skiba <abx### [at] babilonorg>  wrote:

> I can confirm however I wonder if it could be ... floating point accuracy.
> What rounding is performed when float is converted to integer ? Truncation
> towards zero ? Could it be that -1 is internally something like -0.99999999999
> and after truncation it is valid value 0 ?

The rounding method used requires a small bias to be added.  That is added
always.  It can of coure be fixed.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.