Adding functions to Standard Library
This commit is contained in:
parent
808d4ca420
commit
4a21ff3d46
39 changed files with 1465 additions and 51 deletions
33
src/StandardLibrary/Functions/Rounding/Fractional.cs
Normal file
33
src/StandardLibrary/Functions/Rounding/Fractional.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
namespace CSMic.StandardLibrary.Functions.Rounding
|
||||
{
|
||||
public class Fractional : FunctionBase, ICodedFunction
|
||||
{
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "frac";
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<FunctionArgument> ExpectedArguments
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new FunctionArgument("value", FunctionValue.NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
public FunctionValue Execute(params FunctionArgument[] args)
|
||||
{
|
||||
return Execute(args, (_args) =>
|
||||
{
|
||||
var input = _args[0].Value;
|
||||
decimal value = Convert.ToDecimal(input.Value);
|
||||
|
||||
return new FunctionValue(FunctionValueType.Numeric, value - Math.Truncate(value));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue