- a = 1414.165
- b = 15888.9
I need double precision and 7 digits after the dot, so I used pgf floating point functions. Here is the code:
Code: Select all
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{fpu}
%a
\def\a{1414.165}
\pgfmathfloatparsenumber{\a}
\let\ad\pgfmathresult
%b
\def\b{15888.9}
\pgfmathfloatparsenumber{\b}
\let\bd\pgfmathresult
%12
\def\months{12}
\pgfmathfloatparsenumber{\months}
\let\months\pgfmathresult
\begin{document}
\pgfmathfloatdivide{\ad}{\bd}
\pgfmathfloatdivide{\pgfmathresult}{\months}
\pgfmathfloattofixed{\pgfmathresult}
\let\result\pgfmathresult
$\frac{\a}{\b \cdot 12} = \result$
\end{document}
- How to avoid defining float representations of all the variables.
- How to use 12 as a static variable instead of setting it to the variable and converting to float?
- How to avoid calling
\pgfmathfloatdivide
twice and use a nice formula to calculate the result?