POV-Ray : Newsgroups : povray.beta-test : Broken sqr() function implementation. Server Time
20 Jul 2024 05:45:35 EDT (-0400)
  Broken sqr() function implementation. (Message 1 to 1 of 1)  
From: William F Pokorny
Subject: Broken sqr() function implementation.
Date: 7 Aug 2023 08:32:45
Message: <64d0e46d$1@news.povray.org>
There is a long broken (back to v3.7 at least) sqr() function 
implementation sitting in our code.

The fix in my povr (near v3.8) code base was done all in the 
source/parser directory.

In the files reservedwords.h and reservedwords.cpp move SQR_TOKEN to be 
just above SQRT_TOKEN. The order matters in this case.

Plus, in parser_functions.cpp, add the lines:

      case SQR_TOKEN:
          result = pow(node->child->number,2.0);

adjacent to those for the SQRT_TOKEN code.

Once fixed, sqr() will work both in the parser and within functions at 
parse time or run time.

Aside: In regular releases I believe there was a f_sqr() function 
defined. In the povr fork this now a munction resulting in an F_sqr 
function being defined/compiled.

Bill P.

Post a reply to this message

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