-
Notifications
You must be signed in to change notification settings - Fork 1
/
calculator_functions.h
38 lines (24 loc) · 1.03 KB
/
calculator_functions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <math.h>
typedef double(CalculatorCalculateFunctionOneInput)(double a);
typedef double(CalculatorCalculateFunctionTwoInput)(double a, double b);
typedef enum {
CalculatorFunctionTypeOneInput, // Real functions like sqrt, sinx, squared, etc
CalculatorFunctionTypeTwoInput, // Operations multiplying and dividing
CalculatorFunctionTypePassive, // Add and subtract
} CalculatorFunctionType;
typedef struct {
CalculatorFunctionType type;
CalculatorCalculateFunctionOneInput* one_param_func;
CalculatorCalculateFunctionTwoInput* two_param_func;
} CalculatorFunction;
double add(double a);
double subtract(double a);
double multiply(double a, double b);
double divide(double a, double b);
double square(double a);
extern const CalculatorFunction CalculatorFunctionAdd;
extern const CalculatorFunction CalculatorFunctionSubtract;
extern const CalculatorFunction CalculatorFunctionMultiply;
extern const CalculatorFunction CalculatorFunctionDivide;
extern const CalculatorFunction CalculatorFunctionSquare;