Skip to content

Commit

Permalink
Added GAP_ValueMacFloat to libgap-api
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasguts committed Nov 18, 2018
1 parent 243b796 commit 3fa660a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/libgap-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "gvars.h"
#include "integer.h"
#include "lists.h"
#include "macfloat.h"
#include "opers.h"
#include "plist.h"
#include "streams.h"
Expand Down Expand Up @@ -313,3 +314,21 @@ Obj GAP_CharWithValue(UChar obj)
{
return ObjsChar[obj];
}

double GAP_ValueMacFloat(Obj obj)
{
if (!IS_MACFLOAT(obj)) {
ErrorMayQuit("<obj> is not a MacFloat", 0, 0);
}
return (double)VAL_MACFLOAT(obj);
}

Obj GAP_NewMacFloat(double x)
{
return NEW_MACFLOAT(x);
}

Int GAP_IsMacFloat(Obj obj)
{
return IS_MACFLOAT(obj);
}
14 changes: 14 additions & 0 deletions src/libgap-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,18 @@ extern Int GAP_ValueOfChar(Obj obj);
// Returns the GAP character object with value <obj>.
extern Obj GAP_CharWithValue(UChar obj);

////
//// floats
////

// Returns the value of the GAP machine float object <obj>.
// If <obj> is not a machine float object, an error is raised.
extern double GAP_ValueMacFloat(Obj obj);

// Returns a new GAP machine float with value <x>.
extern Obj GAP_NewMacFloat(double x);

// Checks if obj is a GAP machine float.
extern Int GAP_IsMacFloat(Obj obj);

#endif

0 comments on commit 3fa660a

Please sign in to comment.