Operator MOD
#57
(11-30-2022, 03:49 AM)SMcNeill Wrote:
(11-30-2022, 02:50 AM)Kernelpanic Wrote: Oh, and is that correct?  Huh

[Image: MOD-Negative-Zahlen2022-11-29.jpg]


Is 2, or -2, the correct answer to SQR(4)?

BOTH are valid results.  You just need to choose one or the other.  Wink

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
c = a \ b
Print c

I wrote a little program to explain this for myself.
Code: (Select All)
'Beispiele fuer MOD - 30. Nov. 2022

Option _Explicit

Dim As Integer a, b, c
Dim As Single f, fganz, frest

a = 13: b = 5

Print

'Liefert den Rest einer ganzzahligen Division
'Returns the remainder of an integer division
c = a Mod b
Print Using "MOD liefer den Rest von 13 MOD 5: ##"; c

Print

'Teilt ganzzahlig ohne Rest. Zeigt die Anzahl von b in a.
'Divides integer with no remainder. Returns the number of b in a.
c = a \ b
Print Using "Anzahl von 5 in 13: ## "; c

Print

'Mit Fliesskommazahlen
f = 7.456
frest = Abs(f - Fix(f))
fganz = f - frest
Print Using "Ganzzahl von 7.456: ##"; fganz
Print Using "Nachkommateil von 7.456: .###"; frest

Print
c = fganz Mod b
Print "Ganzzahl MOD b: ";
Print c

Print
c = Fix(f) Mod b
Print "Und das Ganze direkt mit Fix(f): ";
Print c

End
Reply


Messages In This Thread
Operator MOD - by Chris - 11-27-2022, 07:09 PM
RE: Operator MOD - by Pete - 11-27-2022, 07:35 PM
RE: Operator MOD - by Chris - 11-27-2022, 07:47 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 08:03 PM
RE: Operator MOD - by Chris - 11-27-2022, 08:17 PM
RE: Operator MOD - by Pete - 11-27-2022, 08:23 PM
RE: Operator MOD - by Chris - 11-27-2022, 08:30 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 08:44 PM
RE: Operator MOD - by mnrvovrfc - 11-27-2022, 08:32 PM
RE: Operator MOD - by bplus - 11-27-2022, 08:42 PM
RE: Operator MOD - by Chris - 11-27-2022, 08:54 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 08:57 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 09:02 PM
RE: Operator MOD - by Jack - 11-27-2022, 09:02 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:02 PM
RE: Operator MOD - by SMcNeill - 11-27-2022, 09:06 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:08 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:14 PM
RE: Operator MOD - by Jack - 11-27-2022, 09:18 PM
RE: Operator MOD - by Pete - 11-27-2022, 09:23 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:28 PM
RE: Operator MOD - by Chris - 11-27-2022, 09:52 PM
RE: Operator MOD - by Pete - 11-27-2022, 10:41 PM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 01:17 AM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 04:01 AM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 02:57 AM
RE: Operator MOD - by Pete - 11-28-2022, 03:21 AM
RE: Operator MOD - by Jack - 11-28-2022, 10:13 AM
RE: Operator MOD - by Kernelpanic - 11-28-2022, 04:03 PM
RE: Operator MOD - by Jack - 11-28-2022, 11:56 AM
RE: Operator MOD - by Chris - 11-28-2022, 03:21 PM
RE: Operator MOD - by Chris - 11-28-2022, 04:06 PM
RE: Operator MOD - by Pete - 11-28-2022, 07:02 PM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 08:23 PM
RE: Operator MOD - by SMcNeill - 11-28-2022, 09:54 PM
RE: Operator MOD - by mnrvovrfc - 11-28-2022, 10:10 PM
RE: Operator MOD - by Pete - 11-28-2022, 10:23 PM
RE: Operator MOD - by Kernelpanic - 11-29-2022, 11:12 PM
RE: Operator MOD - by SMcNeill - 11-28-2022, 10:33 PM
RE: Operator MOD - by Kernelpanic - 11-28-2022, 11:46 PM
RE: Operator MOD - by mnrvovrfc - 11-29-2022, 12:10 AM
RE: Operator MOD - by Pete - 11-29-2022, 12:00 AM
RE: Operator MOD - by Kernelpanic - 11-29-2022, 12:05 AM
RE: Operator MOD - by SMcNeill - 11-29-2022, 12:35 AM
RE: Operator MOD - by Kernelpanic - 11-29-2022, 12:25 AM
RE: Operator MOD - by Pete - 11-29-2022, 12:36 AM
RE: Operator MOD - by bplus - 11-29-2022, 01:29 AM
RE: Operator MOD - by Pete - 11-29-2022, 01:42 AM
RE: Operator MOD - by bplus - 11-29-2022, 04:41 AM
RE: Operator MOD - by SMcNeill - 11-29-2022, 06:24 AM
RE: Operator MOD - by SMcNeill - 11-29-2022, 06:34 AM
RE: Operator MOD - by bplus - 11-29-2022, 12:27 PM
RE: Operator MOD - by Pete - 11-29-2022, 11:58 PM
RE: Operator MOD - by Kernelpanic - 11-30-2022, 02:50 AM
RE: Operator MOD - by SMcNeill - 11-30-2022, 03:49 AM
RE: Operator MOD - by Kernelpanic - 12-01-2022, 12:41 AM
RE: Operator MOD - by vince - 11-30-2022, 12:41 PM
RE: Operator MOD - by Chris - 12-03-2022, 08:19 AM
RE: Operator MOD - by SMcNeill - 12-03-2022, 08:31 AM
RE: Operator MOD - by Pete - 12-03-2022, 09:06 AM
RE: Operator MOD - by mnrvovrfc - 12-03-2022, 11:56 AM
RE: Operator MOD - by SMcNeill - 12-03-2022, 12:08 PM
RE: Operator MOD - by Kernelpanic - 12-03-2022, 05:07 PM
RE: Operator MOD - by Pete - 12-03-2022, 05:12 PM
RE: Operator MOD - by Kernelpanic - 12-03-2022, 05:20 PM
RE: Operator MOD - by SMcNeill - 12-03-2022, 12:30 PM
RE: Operator MOD - by mnrvovrfc - 12-03-2022, 12:31 PM
RE: Operator MOD - by Pete - 12-03-2022, 03:31 PM
RE: Operator MOD - by DSMan195276 - 12-03-2022, 05:57 PM
RE: Operator MOD - by Kernelpanic - 12-03-2022, 06:48 PM
RE: Operator MOD - by Pete - 12-03-2022, 06:05 PM



Users browsing this thread: 22 Guest(s)