Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GAP_ValueMacFloat to libgap-api #3007

Merged
merged 1 commit into from
Nov 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 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 @@ -194,6 +195,29 @@ Obj GAP_CallFuncArray(Obj func, UInt narg, Obj args[])
}


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

Int GAP_IsMacFloat(Obj obj)
{
return IS_MACFLOAT(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);
}


////
//// integers
////
Expand Down
17 changes: 16 additions & 1 deletion src/libgap-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,25 @@ extern Obj GAP_Fail;
extern Obj GAP_CallFuncList(Obj func, Obj args);

// Call the GAP object <func> as a function with arguments given
// as an array <args> with <narg> entries
// as an array <args> with <narg> entries.
extern Obj GAP_CallFuncArray(Obj func, UInt narg, Obj args[]);


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

// Returns 1 if <obj> is a GAP machine float, 0 if not.
extern Int GAP_IsMacFloat(Obj obj);

// 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);


////
//// integers
////
Expand Down