Demonstrating the different FormatStyle options on a floating-point calculation.

ID: 1475

				
					using uCalcSoftware;

var uc = new uCalc();
var expr = uc.Parse("12345.6789");

// Default (General with up to 15 digits)
Console.WriteLine(expr.EvaluateStr(FormatStyle.Default));

// Fixed notation with 2 decimal places
Console.WriteLine(expr.EvaluateStr(FormatStyle.Fixed, 2));

// Scientific notation with 3 decimal places
Console.WriteLine(expr.EvaluateStr(FormatStyle.Scientific, 3));

// General notation constrained to 4 significant digits
Console.WriteLine(expr.EvaluateStr(FormatStyle.General, 4));

// Hexadecimal floating-point notation
Console.WriteLine(expr.EvaluateStr(FormatStyle.Hex));
				
			
12345.6789
12345.68
1.235e+04
1.235e+04
1.81cd6e631f8a1p+13
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto expr = uc.Parse("12345.6789");

   // Default (General with up to 15 digits)
   cout << expr.EvaluateStr(FormatStyle::Default) << endl;

   // Fixed notation with 2 decimal places
   cout << expr.EvaluateStr(FormatStyle::Fixed, 2) << endl;

   // Scientific notation with 3 decimal places
   cout << expr.EvaluateStr(FormatStyle::Scientific, 3) << endl;

   // General notation constrained to 4 significant digits
   cout << expr.EvaluateStr(FormatStyle::General, 4) << endl;

   // Hexadecimal floating-point notation
   cout << expr.EvaluateStr(FormatStyle::Hex) << endl;
}
				
			
12345.6789
12345.68
1.235e+04
1.235e+04
1.81cd6e631f8a1p+13
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim expr = uc.Parse("12345.6789")
      
      '// Default (General with up to 15 digits)
      Console.WriteLine(expr.EvaluateStr(FormatStyle.Default))
      
      '// Fixed notation with 2 decimal places
      Console.WriteLine(expr.EvaluateStr(FormatStyle.Fixed, 2))
      
      '// Scientific notation with 3 decimal places
      Console.WriteLine(expr.EvaluateStr(FormatStyle.Scientific, 3))
      
      '// General notation constrained to 4 significant digits
      Console.WriteLine(expr.EvaluateStr(FormatStyle.General, 4))
      
      '// Hexadecimal floating-point notation
      Console.WriteLine(expr.EvaluateStr(FormatStyle.Hex))
   End Sub
End Module
				
			
12345.6789
12345.68
1.235e+04
1.235e+04
1.81cd6e631f8a1p+13