NO IFs !!!

Started by Robert, September 08, 2024, 01:19:38 AM

Previous topic - Next topic

MrBcx

Quote from: Vortex on September 08, 2024, 03:27:46 AM
Hi Robert,

I think it should be equivalent to :

IF (y >= 0) OR (dy <= 0) THEN
    n = - 1
ELSE
    n = 0
END IF


Correct. "n" always receives a value, 0 or -1.

TRUE in BASIC is traditionally -1, so "n" is behaving as a BASIC Boolean type.


All the more remarkable, the original ray trace code was written for a ZX Spectrum home computer

https://en.wikipedia.org/wiki/ZX_Spectrum



Vortex

Hi Robert,

I think it should be equivalent to :

IF (y >= 0) OR (dy <= 0) THEN
    n = - 1
ELSE
    n = 0
END IF

Robert

In MrBcx's uber-Cool Ray Tracing demo,

https://bcxbasiccoders.com/smf/index.php?topic=1176.msg6136#msg6136

I saw this line of code

n = -(y >= 0 OR dy <= 0)

which is equivalent to

IF (y >= 0) OR (dy <= 0) THEN
n = n - 1
END IF


Neat trick !