Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Confusing cycle symmetry problem... a coding puzzle

Author
Message
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 11th Jul 2008 02:03
Here's the code. I'm trying to create a value (VARIABLE1) that changes cyclically based on time.



The problem is, VARIABLE1 decreases faster than it increases. Every cycle returns lower values. But VARIABLE1 is increasing by a fixed value 80 times (from 1 to 80), and then it decreases by the same rate 80 times (81 to 160). Where does the extra decrease come from?
Moe
18
Years of Service
User Offline
Joined: 1st Apr 2006
Location: Sunny California
Posted: 11th Jul 2008 03:00
There isn't an extra decrease. If you look at it closely, it's the same rate. Write up a program to test if you don't believe me.

parrot
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 11th Jul 2008 03:08 Edited at: 11th Jul 2008 03:24
OK, so I took out the ABS and it worked, but can anyone tell me why using ABS gives a different value in this case?

VARIABLE1MAX=863
VAR1=47

abs(VARIABLE1MAX-VAR1)=abs(863-47)=abs(816)=816
(VARIABLE1MAX-VAR1)=(863-47)=816

That should work, but the only change I made was deleting the abs from the code, and that changes things. I want to keep the abs function in the code, so I can use the same syntax for cycles that decrease at the start as for cycles that increase at the start, just by setting different variable values. That way I can copy/paste large chunks of code controlling many processes, and by setting just a few variables, create entirely different effects.

EDIT: I was wrong about the cause of the unexpected values. I spent a long time looking for something that wasn't there... oops.

Login to post a reply

Server time is: 2024-11-25 01:36:13
Your offset time is: 2024-11-25 01:36:13