# Addition & Multiplication of parameter and constant with unit

I want to substract and multiply with an optional parameter and a constant with cm as unit. Like this:

\documentclass{article}
\usepackage{changepage, xintexpr}

\newcommand{\test}[2][1]{
#2
Something else I need \#1 to be 1 at default
}
\begin{document}
\noindent line1
\test{Sampletext}
\end{document}


However (#1 -1) * 0.8cm isn't working.
I've already achieved 0.8cm * #1 by using #1\dimexpr 0.8cm\relax
But I'm unable to get both operations working.
How can I do this?

PS.: Already looked at How to add, subtract, multiply, and divide in plain TeX? but couldn't figure it out...

You can use the e-LaTeX primitive \dimexpr. Note, however, that you need to do the multiplication in the correct order so instead of \dimexpr(#1-1)*0.8cm you need to use \dimexpr0.8cm*(#1-1); see formal syntax rules of \dimexpr \numexpr \glueexpr for more details.

Here is a full MWE:

\documentclass{article}
\usepackage{changepage, xintexpr}

\newcommand{\test}[2][1]{
#2