Issue #256 The interpreter should use integer division (Haskell quot) when dealing with integers in order to match the behaviour of the compiler

This commit is contained in:
Chris Hall 2018-06-23 14:20:40 +10:00
parent e00bdd1df0
commit 42ec03a293

View File

@ -661,6 +661,8 @@ commandMinus [a, b] =
commandDiv :: CommandCallback
commandDiv [a, b] =
return $ case (a, b) of
(XObj (Num IntTy aNum) _ _, XObj (Num IntTy bNum) _ _) ->
Right (XObj (Num IntTy (fromIntegral (quot (round aNum ::Int) (round bNum :: Int)))) (Just dummyInfo) (Just IntTy))
(XObj (Num aty aNum) _ _, XObj (Num bty bNum) _ _) ->
if aty == bty
then Right (XObj (Num aty (aNum / bNum)) (Just dummyInfo) (Just aty))