Convert System.Decimal from C# .NET to double
Show older comments
I am communicating with a Thorlabs DC servo controller via .NET. When I query the motor position it returns the value in system.decimal format. I found some documentation that briefly mentions this format but doesn't explain how to convert it to a usable numerical value.
How can I can I convert this to something usable?
The returned postion variable is attached.
Accepted Answer
More Answers (1)
Grace Kepler
on 30 Dec 2024
Here is an example without using "pos.mat".
>> xdecimal = System.Decimal(100.1)
xdecimal =
Decimal with properties:
Scale: 1
Zero: [1×1 System.Decimal]
One: [1×1 System.Decimal]
MinusOne: [1×1 System.Decimal]
MaxValue: [1×1 System.Decimal]
MinValue: [1×1 System.Decimal]
>> xdouble = System.Decimal.ToDouble(xdec)
xdouble =
100.1000
1 Comment
Walter Roberson
on 30 Dec 2024
Note that System.Decimal is only available on MS Windows.
Categories
Find more on MATLAB Compiler SDK in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!