Created
October 6, 2014 15:23
-
-
Save mrklein/2a2fb972b9b789883822 to your computer and use it in GitHub Desktop.
Arithmetics
This file contains hidden or 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
leading_zero_strip = $(shell echo $$(echo $(1) | sed 's/^0*//')) | |
__plus = $(shell echo $$(($(1) + $(2)))) | |
plus = $(call __plus,$(call leading_zero_strip,$(1)),$(call leading_zero_strip,$(2))) | |
__minus = $(shell echo $$(($(1) - $(2)))) | |
minus = $(call __minus,$(call leading_zero_strip,$(1)),$(call leading_zero_strip,$(2))) | |
__mult = $(shell echo $$(($(1) * $(2)))) | |
mult = $(call __mult,$(call leading_zero_strip,$(1)),$(call leading_zero_strip,$(2))) | |
__div = $(shell echo $$(($(1) / $(2)))) | |
div = $(call __div,$(call leading_zero_strip,$(1)),$(call leading_zero_strip,$(2))) | |
A = 5 | |
B = 10 | |
C = 45 | |
.DEFAULT: all | |
all: | |
@echo $(call plus,$(A),$(B)) | |
@echo $(call minus,$(C),$(A)) | |
@echo $(call mult,$(A),$(B)) | |
@echo $(call div,$(C),$(A)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment