CoffeeManOhYesIAm
Technical User
Crystal 8.5
Hi everyone,
I've been banging my head against this formula but can't figure it out. It should be pretty simple as it basically tries to define variables based on the value of other variables that are already defined. Here's my formula code:
All pretty straightforward I think. I'm trying to set the dif variable to a number that's less than zero, but may vary from .0001 to .9999. Then I want to know if that number is evenly divisible by 3, so I should take the [blue]remainder[/blue] of it, right? And if the remainder is zero, then the number is divisible by 3.
Seems simple to me, but the funny thing is that my conditional statements are not working. Here is my output:
And the dif is 0.0030
And the dif * 10 is 0.0300 // Huh? it works in the totext() function but not the assignment operator??
And the n1 is 0.0000
And the n2 is 0.0000
And the n3 is 0.0000
And the n4 is 0.0000
And the num is 0.0000
And the answer is 0.0000
Could somebody PLEASE tell me what's going on? Where is the flaw in my reasoning?
Thanks in advance,
Geoff
Hi everyone,
I've been banging my head against this formula but can't figure it out. It should be pretty simple as it basically tries to define variables based on the value of other variables that are already defined. Here's my formula code:
Code:
[blue]numberVar[/blue] dif;
[blue]numberVar[/blue] n1;
[blue]numberVar[/blue] n2;
[blue]numberVar[/blue] n3;
[blue]numberVar[/blue] n4;
[blue]numberVar[/blue] num;
[blue]numberVar[/blue] answer;
dif := .003;
[blue]if[/blue](dif < 0) [blue]then[/blue] n1 := (dif * 10) [blue]else[/blue] num := dif;
[blue]if[/blue](n1 < 0) [blue]then[/blue] n2 := n1 * 10 [blue]else[/blue] num := n1;
[blue]if[/blue](n2 < 0) [blue]then[/blue] n3 := n2 * 10 [blue]else[/blue] num := n2;
[blue]if[/blue](n3 < 0) [blue]then[/blue] n4 := n3 * 10 [blue]else[/blue] num := n3;
[blue]if[/blue](n4 >= 0) [blue]then[/blue] num := n4;
answer := [blue]remainder[/blue](num,3);
"And the dif is " + [blue]totext[/blue](dif) + chr(13) +
"And the dif * 10 is " + [blue]totext[/blue](dif * 10) + chr(13) +
"And the n1 is " + [blue]totext[/blue](n1) + chr(13) +
"And the n2 is " + [blue]totext[/blue](n2) + chr(13) +
"And the n3 is " + [blue]totext[/blue](n3) + chr(13) +
"And the n4 is " + [blue]totext[/blue](n4) + chr(13) +
"And the num is " + [blue]totext[/blue](num) + chr(13) +
"And the answer is " + [blue]totext[/blue](answer) + chr(13)
All pretty straightforward I think. I'm trying to set the dif variable to a number that's less than zero, but may vary from .0001 to .9999. Then I want to know if that number is evenly divisible by 3, so I should take the [blue]remainder[/blue] of it, right? And if the remainder is zero, then the number is divisible by 3.
Seems simple to me, but the funny thing is that my conditional statements are not working. Here is my output:
And the dif is 0.0030
And the dif * 10 is 0.0300 // Huh? it works in the totext() function but not the assignment operator??
And the n1 is 0.0000
And the n2 is 0.0000
And the n3 is 0.0000
And the n4 is 0.0000
And the num is 0.0000
And the answer is 0.0000
Could somebody PLEASE tell me what's going on? Where is the flaw in my reasoning?
Thanks in advance,
Geoff