12-01-2022, 12:41 AM
(This post was last modified: 12-01-2022, 12:42 AM by Kernelpanic.)
(11-30-2022, 03:49 AM)SMcNeill Wrote:(11-30-2022, 02:50 AM)Kernelpanic Wrote: 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.
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