Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Operator MOD
#41
(11-29-2022, 12:00 AM)Pete Wrote: Nice! That's a keeper.

I wish I had your math teacher in high school. Well, not really. Mine had big boobs. She probably taught that MOD trick, but I probably missed it because I was too busy concentrating on the power of 2.

Pete
Stay cool, Pete!  Big Grin

Reply
#42
(11-28-2022, 11:46 PM)Kernelpanic Wrote: I just use Julia for that. . . I also installed it because the name turned me on so much.  Heart
Ohh.. "Do it to Julia! Do it to Julia!!!"

Traitor. Dumbo-cough. ROFLMAO. Thanks Winston for putting "1984" as one of the most disappointing things I had to read, after the somewhat amusing "Animal Farm" by George Orwell. Darn it loved "Boxer" the horse the most. The soldier, only knew how to follow, and the strongest. Thus when he died in the story I cried. Just before that, "Benjamin" was running after the wagon that held his best friend yelling at the other animals to help him rescue "Boxer". "Boxer fight for your life, they're going to take you to the glue factory!"

Anyway this has been one of my favorite ladies' names for a long time:

https://en.wikipedia.org/wiki/X-23

Also like "her clone's" name but that's more for a Venezuelan family serial actress LOL. Not official shortened name though, that's from me.

Sorry, off-topic and this is a very depressing time of year coming up for me...
Reply
#43
Quote: The soldier, only knew how to follow, and the strongest. Thus when he died in the story I cried.

Off . . .
Are you interested in history - and the history of mankind is a history of war?
Then I recommend you the history of the American Civil War (if you don't already know it) for example: "Battle Cry Of Freedom - The Civil War Era", James M. McPherson

BATTLE CRY OF FREEDOM: The Civil War Era
Reply
#44
(11-29-2022, 12:00 AM)Pete Wrote: Nice! That's a keeper.

I wish I had your math teacher in high school. Well, not really. Mine had big boobs. She probably taught that MOD trick, but I probably missed it because I was too busy concentrating on the power of 2.

Pete

I remember those days of 58008 glory.  

When you think about it, the Negative MOD of a number has to be the same as the positive MOD.

After all, how do you get MOD to begin with??   Repetitive subtraction!

27 MOD 5
27 - 5
22 - 5
17 - 5
12 - 5
 7 - 5
 2 - 5...   can't subtract so 2 is the answer.

27 MOD -5
27 + -5 
22 + -5
17 + -5
12 + -5
7 + -5
2 + -5....  can't add so 2 is the answer.

Subtract one... add the other...  The trick is to always approach zero.  As D.J. Keith stressed for us, "that + and - is just *direction* you're traveling in."  

In this case, you always want to travel towards 0, to find your answer.

(X MOD Y)= (X MOD -Y)...   They're basically the same, as far as I can tell.
Reply
#45
We usually get off topic after a thread has been properly beat to death. I rather like that, in fact.

Also at mn, sorry to hear this time of year is depressing for you. If it's seasonal depression, I get it. I don't know what I'd do outside the sunny skies of Cali. I've had older friends who moved to Oregon, and wish they could move back. Anyway, stay tuned to the Phoenix forum. Steve and I will be sure to turn up the heat here this winter. Oh, and for my many friends from Australia, who Thanksgiving was completely lost on... Happy 4th of July!

Pete
Reply
#46
SAD? When it's pitch black at 5 PM and clouds roll in from over the lake and stay to about March, it definitely gets bleak in N. Ohio.

But now we have Modulus for Negative numbers!
b = b + ...
Reply
#47
Hey remember when the mid-west actually had seasons? 1960 - 1970 something. Things started to change in the 1980's. Mostly summer and winter with a couple weeks of transition. That was real climate change. Not the BS we keep hearing about today.

Well I hoe Chris can actually make use of what we came up with in this thread. I mean any keyword is basically a function running in the background, so when he states none of these functions  will meet his requirements, I wonder how on earth a single keyword might? Is it just more involved as in floating point differences? I didn't bother to get that far down this rabbit hole.

Pete
Reply
#48
Thumbs Up 
(11-29-2022, 12:35 AM)SMcNeill Wrote:
(11-29-2022, 12:00 AM)Pete Wrote: Nice! That's a keeper.

I wish I had your math teacher in high school. Well, not really. Mine had big boobs. She probably taught that MOD trick, but I probably missed it because I was too busy concentrating on the power of 2.

Pete

I remember those days of 58008 glory.  

When you think about it, the Negative MOD of a number has to be the same as the positive MOD.

After all, how do you get MOD to begin with??   Repetitive subtraction!

27 MOD 5
27 - 5
22 - 5
17 - 5
12 - 5
 7 - 5
 2 - 5...   can't subtract so 2 is the answer.

27 MOD -5
27 + -5 
22 + -5
17 + -5
12 + -5
7 + -5
2 + -5....  can't add so 2 is the answer.

Subtract one... add the other...  The trick is to always approach zero.  As D.J. Keith stressed for us, "that + and - is just *direction* you're traveling in."  

In this case, you always want to travel towards 0, to find your answer.

(X MOD Y)= (X MOD -Y)...   They're basically the same, as far as I can tell.

I like this explanation, points me towards getting a handle on floats, and thanks for simplifying Pete's ABS & SGN laden thing!
b = b + ...
Reply
#49
Another simple explanation for you @bplus:

Think of what MOD is...   It's the remainder after division...  nothing more, nothing less.

INT(27 / 5) = 5
5 * 5 = 25
27 - 25 = 2
2 is the remainder.

INT(27 / -5) = -5
-5 * -5 = 25
27 - 25 = 2
2 is the remainder.

INT(-27 / 5) = -6
5 * -6 = -30
-27 - -30 = 3
3 is the answer.

It's that simple.  Wink
Reply
#50
Maybe this SUPER simple formula will show how it works:

Code: (Select All)
For i = -10 To 10
    Print Steve_ModX(i, 5), Steve_ModX2(i, 5), Steve_ModX3(i, 5)
Next


Function Steve_ModX (num1, num2)
    Steve_ModX = ((num1 Mod num2) + Abs(num2)) Mod num2
End Function


Function Steve_ModX2 (num1, num2)
    Steve_ModX2 = num1 - (Int(num1 / num2) * num2)
End Function

Function Steve_ModX3 (num1, num2)
    Steve_ModX3 = num1 - (num1 \ num2) * num2
End Function


And this even showcases how QB64 gets the answer that it goes for us, with ModX3.  

INT(x / y) is NOT the same as x \ y.
Reply




Users browsing this thread: 16 Guest(s)