Skip to content

Commit

Permalink
Replace non-normative paragraph by three-part example
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Nov 22, 2022
1 parent 9db33e7 commit ffb6612
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions chapters/operatorsandexpressions.tex
Expand Up @@ -542,9 +542,19 @@ \subsection{Numeric Functions and Conversion Functions}\label{numeric-functions-

The `\lstinline!x!'/`\lstinline!X!' formats (hexa-decimal) and \lstinline!c! (character) for \lstinline!Integer! values give results that do not agree with the Modelica grammar.

\begin{nonnormative}
Since no automatic type coerction takes place for the first argument of \lstinline!String(4, format = ".5f")!, an implementation the \lstinline!Integer! case of \lstinline!String! may internally convert the value to floating point and then fall back on the \lstinline!Real! case implementation of \lstinline!format = ".5f"!.
\end{nonnormative}
\begin{example}
Some situations worth a remark:
\begin{itemize}
\item
\lstinline!String(4.0, format = "g")! produces \emph{4} which is not a valid \lstinline!Real! literal.
However, it is an \lstinline!Integer! literal that can be used almost anywhere in Modelica code instead of the \lstinline!Real! literal \lstinline{4.0} (with the first argument to \lstinline!String! being a notable exception here).
\item
\lstinline!String(4, format = ".3f")! uses the \lstinline!Integer! case of \lstinline!String! since no automatic type coerction takes place for the first argument.
An implementation may internally convert the value to floating point and then fall back on the \lstinline!Real! case implementation of \lstinline!format = ".3f"!.
\item
\lstinline!String(4611686018427387648, format = ".0f")! (a valid \lstinline!Integer! value in an implementation with 64 bit \lstinline!IntegerType!) may produce \emph{4611686018427387904} (not equal to input value), in case internal conversion to a 64 bit \lstinline[language=C]!double! is applied.
\end{itemize}
\end{example}
\end{semantics}
\end{operatordefinition*}

Expand Down

0 comments on commit ffb6612

Please sign in to comment.