[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[s8] division and reminder



"a\\b (a=5 b=1.5)"
(5 \\ 1.5 = (5 - (5 // 1.5 * 1.5))) ifFalse: [
	self error: 'Wrong result'
]


"a\\b (a=5 b=7)" 
(5 \\ 7 = (5 - (5 // 7 * 7))) ifFalse: [
	self error: 'Wrong result'
]


"a\\b (a=5 b=8.5)" 
(5 \\ 8.5 = (5 - (5 // 8.5 * 8.5))) ifFalse: [
	self error: 'Wrong result'
]



"a\\b (a=5 b=2)" 
(5 \\ 2 = (5 - (5 // 2 * 2))) ifFalse: [
	self error: 'Wrong result'
]


"a\\b (a=5 b=-1.5)" 
(5 \\ -1.5 = (5 - (5 // -1.5 * -1.5))) ifFalse: [
	self error: 'Wrong result'
]


"a\\b (a=-5 b=7)" 
(-5 \\ 7 = (-5 - (-5 // 7 * 7))) ifFalse: [
	self error: 'Wrong result'
]


"a\\b (a=-5 b=7)"
(-5 \\ 7 = (-5 - (-5 // 7 * 7))) ifFalse: [
	self error: 'Wrong result'
].


"a\\b (a=-5 b=8.5) "
(-5 \\ 8.5 = (-5 - (-5 // 8.5 * 8.5))) ifFalse: [
	self error: 'Wrong result'
]


"a\\b (a=5 b=-2)"
(5 \\ -2 = (5 - (5 // -2 * -2))) ifFalse: [
	self error: 'Wrong result'
]


"a\\b (a=5.5 b=2)"
(5.5 \\ 2 = (5.5 - (5.5 // 2 * 2))) ifFalse: [
	self error: 'Wrong result'
]


"Zero divisor on remainer"
[5 \\ 0] on: Error do: [:ex | ^#Ok ].
self error: 'Must trigger an Error'


"Zero divisor"
[5 // 0] on: Error do: [:ex | ^#Ok ].
self error: 'Must trigger an Error'


"Integer division (5 // 2 = 2)"
5 // 2 = 2 ifFalse: [ self error: 'Wrong result' ].


"Integer division (2 // 5 = 0)"
2 // 5 = 0 ifFalse: [ self error: 'Wrong result' ].


"Integer division (5.5 // -2.2 = -3)"
5.5 // -2.2 = -3 ifFalse: [ self error: 'Wrong result' ].


"Integer division (-5.5 // -2.2 = 2)"
-5.5 // -2.2 = 2 ifFalse: [ self error: 'Wrong result' ].