# -------------------------------------
# Some Helpful arithmetics
# -------------------------------------
#Addition
ADD = $(shell echo $(1)+$(2) | bc)
#Subtraction
SUBTRACT = $(shell echo $(1)-$(2) | bc)
#Multiplication
MULTIPLY = $(shell echo $(1)*$(2) | bc)
#Division
DIVIDE = $(shell echo $(1)/$(2) | bc)
#Division (Floating Point)
DIVIDEF = $(shell echo "scale=3; $(2)/$(1)" | bc)
#Modulo
MODULO = $(shell echo $(1)%$(2) | bc)
#Comparison Greater Than
COMPARISON1 = $(shell echo $(1)\>=$(2) | bc)
#Comparison Smaller Than
COMPARISON2 = $(shell echo $(2)\<=$(2) | bc)
and how you use them:
# Function = a*15+b*33+2
Function = $(call ADD,$(call ADD,$(call MULTIPLY,$(1),15)),$(call MULTIPLY,$(2),33),2)
# calling the function
test:
echo $(call Function,4,5)
Got a better idea?
No comments:
Post a Comment