8000 Enable ll functions · ChaiScript/ChaiScript_Extras@670d0e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 670d0e0

Browse files
committed
Enable ll functions
Trying to determine which compiler(s) they work on
1 parent fe8f672 commit 670d0e0

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

include/chaiscript/extras/math.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#include <cmath>
22
#include <memory>
33

4-
#include "../dispatchkit/dispatchkit.hpp"
5-
#include "../chaiscript.hpp"
4+
#include <chaiscript/chaiscript.hpp>
65

76
namespace chaiscript {
87
namespace extras {
@@ -300,12 +299,12 @@ namespace chaiscript {
300299
}
301300

302301
// long long ints do not work
303-
/*template<typename Ret, typename Param>
302+
template<typename Ret, typename Param>
304303
ModulePtr llround(ModulePtr m = std::make_shared<Module>())
305304
{
306305
m->add(chaiscript::fun(static_cast<Ret (*)(Param)>(&std::llround)), "llround");
307306
return m;
308-
}*/
307+
}
309308

310309
template<typename Ret, typename Param>
311310
ModulePtr rint(ModulePtr m = std::make_shared<Module>())
@@ -322,12 +321,12 @@ namespace chaiscript {
322321
}
323322

324323
// long long ints do not work
325-
/*template<typename Ret, typename Param>
324+
template<typename Ret, typename Param>
326325
ModulePtr llrint(ModulePtr m = std::make_shared<Module>())
327326
{
328327
m->add(chaiscript::fun(static_cast<Ret (*)(Param)>(&std::llrint)), "llrint");
329328
return m;
330-
}*/
329+
}
331330

332331
template<typename Ret, typename Param>
333332
ModulePtr nearbyint(ModulePtr m = std::make_shared<Module>())
@@ -683,9 +682,9 @@ namespace chaiscript {
683682
lround<long int, long double>(m);
684683

685684
// long long ints do not work
686-
/*llround<long long int, double>(m);
685+
llround<long long int, double>(m);
687686
llround<long long int, float>(m);
688-
llround<long long int, long double>(m);*/
687+
llround<long long int, long double>(m);
689688

690689
rint<double, double>(m);
691690
rint<float, float>(m);
@@ -696,9 +695,9 @@ namespace chaiscript {
696695
lrint<long int, long double>(m);
697696

698697
// long long ints do not work
699-
/*llrint<long long int, double>(m);
698+
llrint<long long int, double>(m);
700699
llrint<long long int, float>(m);
701-
llrint<long long int, long double>(m);*/
700+
llrint<long long int, long double>(m);
702701

703702
nearbyint<double, double>(m);
704703
nearbyint<float, float>(m);

tests/math.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
2+
//#include <sstream>
23
#include "catch.hpp"
34

45
#include <chaiscript/chaiscript.hpp>
@@ -68,10 +69,10 @@ TEST_CASE( "Math functions work", "[math]" ) {
6869
CHECK(chai.eval<double>("trunc(0.5)") == trunc(0.5));
6970
CHECK(chai.eval<double>("round(0.5)") == round(0.5));
7071
CHECK(chai.eval<long int>("lround(0.5)") == lround(0.5));
71-
// CHECK(chai.eval<double>("llround(0.5)") == llround(0.5)); // long longs do not work
72+
CHECK(chai.eval<long long int>("llround(0.5)") == llround(0.5)); // long longs do not work
7273
CHECK(chai.eval<double>("rint(0.5)") == rint(0.5));
7374
CHECK(chai.eval<long int>("lrint(0.5)") == lrint(0.5));
74-
// CHECK(chai.eval<double>("llrint(0.5)") == llrint(0.5));
75+
CHECK(chai.eval<long long int>("llrint(0.5)") == llrint(0.5));
7576
CHECK(chai.eval<double>("nearbyint(0.5)") == nearbyint(0.5));
7677
CHECK(chai.eval<double>("remainder(6.0, 2.5)") == remainder(6.0, 2.5));
7778
int quot = 0; CHECK(chai.eval<double>("var quot = 0\nremquo(6.0, 2.5, quot)") == remquo(6.0, 2.5, &quot));

0 commit comments

Comments
 (0)
0