Operator MOD - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2) +--- Thread: Operator MOD (/showthread.php?tid=1195) |
RE: Operator MOD - bplus - 11-29-2022 Sorry forgot to get quote for next page, referring to this: https://staging.qb64phoenix.com/showthread.php?tid=1195&pid=10829#pid10829 Not sure Steve_Mod of the third type will work with Singles, Doubles, _Floats with the Integer Division. I see precision problems coming back to haunt us with decimal point numbers, the Reals, probably with Steve_Mod of the 2nd type. RE: Operator MOD - Kernelpanic - 11-29-2022 (11-28-2022, 10:23 PM)Pete Wrote: Steve, yours needs some work if you pop a negatives in there as the modulo. This gives correct results. What I don't understand is why the program should be wrong because of an addendum? That way I can make any program skid. Code: (Select All) Function Steve_ModX (num1, num2) Steve_ModX = ((num1 Mod num2) + Abs(num2)) Mod num2 RE: Operator MOD - Pete - 11-29-2022 Steve updated his function so it would match my routine's capability to work with both positive and negative modulos. Pete RE: Operator MOD - Kernelpanic - 11-30-2022 (11-29-2022, 11:58 PM)Pete Wrote: Steve updated his function so it would match my routine's capability to work with both positive and negative modulos.Oh, and is that correct? RE: Operator MOD - SMcNeill - 11-30-2022 (11-30-2022, 02:50 AM)Kernelpanic Wrote:(11-29-2022, 11:58 PM)Pete Wrote: Steve updated his function so it would match my routine's capability to work with both positive and negative modulos.Oh, and is that correct? Is 2, or -2, the correct answer to SQR(4)? BOTH are valid results. You just need to choose one or the other. RE: Operator MOD - vince - 11-30-2022 that's both a two and a negative two for all you nobodies RE: Operator MOD - Kernelpanic - 12-01-2022 (11-30-2022, 03:49 AM)SMcNeill Wrote:(11-30-2022, 02:50 AM)Kernelpanic Wrote: Oh, and is that correct? Hmm, I do not know! This one: -9 MOD -5 = 1 looks to me: Divides integer with no remainder. Shows the number of b in a. Code: (Select All) a = -9: b = -5 I wrote a little program to explain this for myself. Code: (Select All) 'Beispiele fuer MOD - 30. Nov. 2022 RE: Operator MOD - Chris - 12-03-2022 What problem do You have with implementing a new function to QB64 in the form of: MODn(y , x) = y - x * INT(y / x) or (y MODn x) = y - x * INT(y / x) All it takes is a little good will. If no one has it, well... As of today, the MOD is unusable. Regards - Chris RE: Operator MOD - SMcNeill - 12-03-2022 (12-03-2022, 08:19 AM)Chris Wrote: What problem do You have with implementing a new function to QB64 in the form of: What problem do you have in adding and implementing that function into your own code??? As of today, YOUR code is unusable. Nobody else is having any problem. RE: Operator MOD - Pete - 12-03-2022 >>> MODn(y , x) = y - x * INT(y / x) Another nice integer modula formula, but I'd tweak it to handle negative mods... Code: (Select All) $CONSOLE:ONLY Pete |