Number conversions
This page was created by Hans.karlsen@mdriven.net on 2021-07-30. Last edited by Stephanie@mdriven.net on 2025-01-22.

The numeric types float, double, decimal and int are sort of apples of the same tree and MDriven expose ways to go from all numeric types to decimal. The operator is called toDecimal.

Sometimes you may want to assign from one type to another like this:

self.PaymentMenuRequest.VatPercent:=vTypAvBiljett.BiljettPrisMoms

but you get an error like: 998: In ":=", one of the arguments must conform to the other (Nullable<System.Double> and Nullable<System.Decimal> does not)

Solve like this:

self.PaymentMenuRequest.VatPercent:=vTypAvBiljett.BiljettPrisMoms.todouble

These are valid assignments but you change precision and loose fractions when converting to simpler types

self.SomeInt:=self.SomeDouble
self.SomeDouble:=self.SomeInt
self.SomeDecimal:=self.SomeInt
self.SomeDecimal:=self.SomeDouble.todecimal
self.SomeInt:=self.SomeDecimal
self.SomeDouble:=self.SomeDecimal.todouble