Converting a value from a pointer using a specific data type and formatting it.
ID: 1481
using uCalcSoftware;
var uc = new uCalc();
var myVar = uc.DefineVariable("myVar = 255.5");
var ptr = myVar.ValueAddr();
// Get the DataType object for Double
var doubleType = uc.DataTypeOf("Double");
// Read from memory and format as Fixed with 2 decimal places
Console.WriteLine(doubleType.ToString(ptr, FormatStyle.Fixed, 2));
// Read from memory and format with a custom pattern
Console.WriteLine(doubleType.ToString(ptr, "Result = Format('--{:6.1f}--', double(Result))"));
255.50
-- 255.5--
using uCalcSoftware; var uc = new uCalc(); var myVar = uc.DefineVariable("myVar = 255.5"); var ptr = myVar.ValueAddr(); // Get the DataType object for Double var doubleType = uc.DataTypeOf("Double"); // Read from memory and format as Fixed with 2 decimal places Console.WriteLine(doubleType.ToString(ptr, FormatStyle.Fixed, 2)); // Read from memory and format with a custom pattern Console.WriteLine(doubleType.ToString(ptr, "Result = Format('--{:6.1f}--', double(Result))"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto myVar = uc.DefineVariable("myVar = 255.5");
auto ptr = myVar.ValueAddr();
// Get the DataType object for Double
auto doubleType = uc.DataTypeOf("Double");
// Read from memory and format as Fixed with 2 decimal places
cout << doubleType.ToString(ptr, FormatStyle::Fixed, 2) << endl;
// Read from memory and format with a custom pattern
cout << doubleType.ToString(ptr, "Result = Format('--{:6.1f}--', double(Result))") << endl;
}
255.50
-- 255.5--
#include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto myVar = uc.DefineVariable("myVar = 255.5"); auto ptr = myVar.ValueAddr(); // Get the DataType object for Double auto doubleType = uc.DataTypeOf("Double"); // Read from memory and format as Fixed with 2 decimal places cout << doubleType.ToString(ptr, FormatStyle::Fixed, 2) << endl; // Read from memory and format with a custom pattern cout << doubleType.ToString(ptr, "Result = Format('--{:6.1f}--', double(Result))") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim myVar = uc.DefineVariable("myVar = 255.5")
Dim ptr = myVar.ValueAddr()
'// Get the DataType object for Double
Dim doubleType = uc.DataTypeOf("Double")
'// Read from memory and format as Fixed with 2 decimal places
Console.WriteLine(doubleType.ToString(ptr, FormatStyle.Fixed, 2))
'// Read from memory and format with a custom pattern
Console.WriteLine(doubleType.ToString(ptr, "Result = Format('--{:6.1f}--', double(Result))"))
End Sub
End Module
255.50
-- 255.5--
Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim myVar = uc.DefineVariable("myVar = 255.5") Dim ptr = myVar.ValueAddr() '// Get the DataType object for Double Dim doubleType = uc.DataTypeOf("Double") '// Read from memory and format as Fixed with 2 decimal places Console.WriteLine(doubleType.ToString(ptr, FormatStyle.Fixed, 2)) '// Read from memory and format with a custom pattern Console.WriteLine(doubleType.ToString(ptr, "Result = Format('--{:6.1f}--', double(Result))")) End Sub End Module