-
-
Save Dimon70007/7c936bcdfcc6ae03652e5baa64e0d58f to your computer and use it in GitHub Desktop.
Makefile Tricks: Arithmetic – Addition, Subtraction, Multiplication, Division, Modulo, Comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NUMBER1 := 10 | |
NUMBER2 := 5 | |
#Addition | |
ADD := $(shell echo ${NUMBER1}+${NUMBER2} | bc) | |
#Subtraction | |
SUBTRACT := $(shell echo ${NUMBER1}-${NUMBER2} | bc) | |
#Multiplication | |
MULTIPLY := $(shell echo ${NUMBER1}*${NUMBER2} | bc) | |
#Division | |
DIVIDE := $(shell echo ${NUMBER1}/${NUMBER2} | bc) | |
#Division (Floating Point) | |
DIVIDEF := $(shell echo "scale=3; ${NUMBER2}/${NUMBER1}" | bc) | |
#Modulo | |
MODULO := $(shell echo ${NUMBER1}%${NUMBER2} | bc) | |
#Comparison Greater Than | |
COMPARISON1 := $(shell echo ${NUMBER1}\>=${NUMBER2} | bc) | |
#Comparison Smaller Than | |
COMPARISON2 := $(shell echo ${NUMBER2}\<=${NUMBER2} | bc) | |
all: | |
@echo Addition ${ADD} | |
@echo Subtraction ${SUBTRACT} | |
@echo Multiplication ${MULTIPLY} | |
@echo Division ${DIVIDE} | |
@echo Division - Floating Point ${DIVIDEF} | |
@echo Modulo ${MODULO} | |
@echo Comparison Greater Than ${COMPARISON1} | |
@echo Comparison Smaller Than ${COMPARISON2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment