From a7deea90e831c727cb39a22f47c15f5c54b94373 Mon Sep 17 00:00:00 2001 From: Dimitar Trendafilov Date: Mon, 19 Nov 2018 22:25:48 +0200 Subject: Support for double as number type in the runtime --- JSImpl/test/sprtTests.cpp | 2 +- spasm/src/spasm.cpp | 2 +- spasm/src/types.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/JSImpl/test/sprtTests.cpp b/JSImpl/test/sprtTests.cpp index eef7147..787d9eb 100644 --- a/JSImpl/test/sprtTests.cpp +++ b/JSImpl/test/sprtTests.cpp @@ -81,7 +81,7 @@ TEST_F(SPRTTest, Div) }; Run(bytecode, sizeof(bytecode)); - ASSERT_EQ(Output.str(), "0"); + ASSERT_EQ(Output.str(), "0.857143"); } TEST_F(SPRTTest, Mod) diff --git a/spasm/src/spasm.cpp b/spasm/src/spasm.cpp index 8e5e36d..6e09be9 100644 --- a/spasm/src/spasm.cpp +++ b/spasm/src/spasm.cpp @@ -281,7 +281,7 @@ void Spasm::divide(reg_t a0, reg_t a1, reg_t a2) */ void Spasm::modulus(reg_t a0, reg_t a1, reg_t a2) { - set_local(a0, get_local(a1) % get_local(a2)); + set_local(a0, int64_t(get_local(a1)) % int64_t(get_local(a2))); } /*! diff --git a/spasm/src/types.hpp b/spasm/src/types.hpp index 26450db..59562e1 100644 --- a/spasm/src/types.hpp +++ b/spasm/src/types.hpp @@ -9,7 +9,7 @@ namespace SpasmImpl { typedef int8_t byte; typedef size_t PC_t; -typedef int data_t; +typedef double data_t; class Spasm; typedef void (Spasm::*Operation)(); -- cgit v1.3.1-26-gb76a