POV-Ray : Newsgroups : povray.beta-test : int() and val() don't work in functions Server Time
5 Nov 2024 01:26:29 EST (-0500)
  int() and val() don't work in functions (Message 1 to 10 of 10)  
From: Mike Williams
Subject: int() and val() don't work in functions
Date: 17 Sep 2001 13:16:26
Message: <OsdImCAWCep7Ew$O@econym.demon.co.uk>
"floor()" can be used in simple assignments and in functions

#declare A=floor(B);                    //OK
#declare F=function{floor(x)}           //OK

But int() and val() can be used in simple assignments, but can't be used
inside a function

#declare A=int(B);                      // OK
#declare F=function{int(x)}             // Parse Error

#declare A=val("1.4");                  // OK
#declare F=function{x+val("1.4")}       // Parse Error

The docs, page 6.1.6, say int() and val() are permissible in a function.

Actually, we could live quite happily without val() in functions because
it's not going to change its value during the function evaluation, so we
can simply write
        #declare V=val(My_string);
        #declare function{x+V}
in which case remove "val()" from the list on page 6.1.6.

POV 3.5b2, AMD K6-2 500, 128Mb

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: int() and val() don't work in functions
Date: 17 Sep 2001 13:39:57
Message: <3ba6356d@news.povray.org>
In article <OsdImCAWCep7Ew$O@econym.demon.co.uk> , Mike Williams 
<mik### [at] nospamplease>  wrote:

> The docs, page 6.1.6, say int() and val() are permissible in a function.

This is a documentation error.  Sorry for that, it will be corrected.


    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

From: Mike Williams
Subject: Re: int() and val() don't work in functions
Date: 17 Sep 2001 14:54:36
Message: <WmeuUCAZakp7EwcT@econym.demon.co.uk>
Wasn't it Thorsten Froehlich who wrote:
>In article <OsdImCAWCep7Ew$O@econym.demon.co.uk> , Mike Williams 
><mik### [at] nospamplease>  wrote:
>
>> The docs, page 6.1.6, say int() and val() are permissible in a function.
>
>This is a documentation error.  Sorry for that, it will be corrected.

So what do we do if we really want "int()"?

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: int() and val() don't work in functions
Date: 17 Sep 2001 15:37:21
Message: <3ba650f1@news.povray.org>
In article <Wme### [at] econymdemoncouk> , Mike Williams 
<mik### [at] nospamplease>  wrote:

> So what do we do if we really want "int()"?

Actually, could you list the differences between "int" and "floor"?


    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

From: Ron Parker
Subject: Re: int() and val() don't work in functions
Date: 17 Sep 2001 15:56:48
Message: <slrn9qclc2.l3s.ron.parker@fwi.com>
On Mon, 17 Sep 2001 15:37:14 -0400, Thorsten Froehlich wrote:
>In article <Wme### [at] econymdemoncouk> , Mike Williams 
><mik### [at] nospamplease>  wrote:
>
>> So what do we do if we really want "int()"?
>
>Actually, could you list the differences between "int" and "floor"?

I think the difference is the behavior for negative numbers: 
int(-1.5) is -1, but floor(-1.5) is -2.

-- 
#local R=rgb 99;#local P=R-R;#local F=pigment{gradient x}box{0,1pigment{gradient
y pigment_map{[.5F pigment_map{[.3R][.3F color_map{[.15red 99][.15P]}rotate z*45
translate x]}]#local H=pigment{gradient y color_map{[.5P][.5R]}scale 1/3}[.5F
pigment_map{[.3R][.3H][.7H][.7R]}]}}}camera{location.5-3*z}//only my opinions


Post a reply to this message

From: JRG
Subject: Re: int() and val() don't work in functions
Date: 17 Sep 2001 16:29:15
Message: <3ba65d1b@news.povray.org>
According to their definitions... shouldn't they be the same thing?...

"Thorsten Froehlich" <tho### [at] trfde> ha scritto nel messaggio
news:3ba650f1@news.povray.org...
> In article <Wme### [at] econymdemoncouk> , Mike Williams
> <mik### [at] nospamplease>  wrote:
>
> > So what do we do if we really want "int()"?
>
> Actually, could you list the differences between "int" and "floor"?
>
>
>     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

From: Thorsten Froehlich
Subject: Re: int() and val() don't work in functions
Date: 17 Sep 2001 16:36:07
Message: <3ba65eb7@news.povray.org>
In article <slr### [at] fwicom> , ron### [at] povrayorg (Ron
Parker) wrote:

> I think the difference is the behavior for negative numbers:
> int(-1.5) is -1, but floor(-1.5) is -2.

Hmm, do we really need the "int" behavior?  Anyway, I will add it to
functions.

    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

From: Anders K 
Subject: Re: int() and val() don't work in functions
Date: 17 Sep 2001 17:21:33
Message: <3ba6695d@news.povray.org>
> > Actually, could you list the differences between "int" and "floor"?
>
> According to their definitions... shouldn't they be the same thing?...

Yes, they *should* be the same thing... The difference right now is that
floor always rounds down, but int always rounds towards zero (this is
usually called trunc). This also has a rather unfortunate effect on mod,
where, for example, -23 mod 10 is currently -3 when it should be 8.


Post a reply to this message

From: Mike Williams
Subject: Re: int() and val() don't work in functions
Date: 16 Oct 2001 22:03:55
Message: <W8YOyLAqYOz7Ewt8@econym.demon.co.uk>
Wasn't it Thorsten Froehlich who wrote:
>In article <slr### [at] fwicom> , ron### [at] povrayorg (Ron
>Parker) wrote:
>
>> I think the difference is the behavior for negative numbers:
>> int(-1.5) is -1, but floor(-1.5) is -2.
>
>Hmm, do we really need the "int" behavior?  Anyway, I will add it to
>functions.
>
>    Thorsten

Just a reminder. 

The inconsistency between the documentation (6.1.6) and the program
regarding the legality of "int()" withing a user defined function was
noticed back in beta 2. Things are still the same in beta 6, and it
doesn't appear to be on the "known bugs" list.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: int() and val() don't work in functions
Date: 17 Oct 2001 04:33:02
Message: <3BCD41A8.8EB9CA5C@hotmail.com>
Thorsten Froehlich wrote:
> 
> In article <slr### [at] fwicom> , ron### [at] povrayorg (Ron
> Parker) wrote:
> 
> > I think the difference is the behavior for negative numbers:
> > int(-1.5) is -1, but floor(-1.5) is -2.
> 
> Hmm, do we really need the "int" behavior?  Anyway, I will add it to
> functions.

Yes.


Tor Olav


Post a reply to this message

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