Demonstrates enabling multiple floating-point error types and observing the results.

ID: 349

				
					using uCalcSoftware;

var uc = new uCalc();
Console.WriteLine("--- Default Behavior (No Errors Raised) ---");
Console.WriteLine($"1/0: {uc.EvalStr("1/0")}");
Console.WriteLine($"0/0: {uc.EvalStr("0/0")}");
Console.WriteLine($"Overflow (5*10^308): {uc.EvalStr("5*10^308")}");
Console.WriteLine($"Underflow (10^-308/10000): {uc.EvalStr("10^-308/10000")}");

Console.WriteLine("");
Console.WriteLine("--- Enable Invalid Operation & Underflow ---");
// You can pass multiple enum members to enable them simultaneously
uc.Error.SetFloatingPointErrorsToTrap(ErrorCode.FloatInvalid, ErrorCode.FloatUnderflow);
Console.WriteLine($"Current flags: {uc.Error.FloatingPointErrorsToTrap}"); // Should be 16 (Invalid) + 2 (Underflow) = 18

Console.WriteLine($"1/0: {uc.EvalStr("1/0")}"); // Not enabled, returns inf
Console.WriteLine($"0/0: {uc.EvalStr("0/0")}"); // Enabled, raises error
Console.WriteLine($"Overflow (5*10^308): {uc.EvalStr("5*10^308")}"); // Not enabled, returns inf
Console.WriteLine($"Underflow (10^-308/10000): {uc.EvalStr("10^-308/10000")}"); // Enabled, raises error
				
			
--- Default Behavior (No Errors Raised) ---
1/0: inf
0/0: nan
Overflow (5*10^308): inf
Underflow (10^-308/10000): 0

--- Enable Invalid Operation & Underflow ---
Current flags: 18
1/0: inf
0/0: Invalid operation
Overflow (5*10^308): inf
Underflow (10^-308/10000): Floating point underflow
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   cout << "--- Default Behavior (No Errors Raised) ---" << endl;
   cout << "1/0: " << uc.EvalStr("1/0") << endl;
   cout << "0/0: " << uc.EvalStr("0/0") << endl;
   cout << "Overflow (5*10^308): " << uc.EvalStr("5*10^308") << endl;
   cout << "Underflow (10^-308/10000): " << uc.EvalStr("10^-308/10000") << endl;

   cout << "" << endl;
   cout << "--- Enable Invalid Operation & Underflow ---" << endl;
   // You can pass multiple enum members to enable them simultaneously
   uc.Error().SetFloatingPointErrorsToTrap(ErrorCode::FloatInvalid, ErrorCode::FloatUnderflow);
   cout << "Current flags: " << uc.Error().FloatingPointErrorsToTrap() << endl; // Should be 16 (Invalid) + 2 (Underflow) = 18

   cout << "1/0: " << uc.EvalStr("1/0") << endl; // Not enabled, returns inf
   cout << "0/0: " << uc.EvalStr("0/0") << endl; // Enabled, raises error
   cout << "Overflow (5*10^308): " << uc.EvalStr("5*10^308") << endl; // Not enabled, returns inf
   cout << "Underflow (10^-308/10000): " << uc.EvalStr("10^-308/10000") << endl; // Enabled, raises error
}
				
			
--- Default Behavior (No Errors Raised) ---
1/0: inf
0/0: nan
Overflow (5*10^308): inf
Underflow (10^-308/10000): 0

--- Enable Invalid Operation & Underflow ---
Current flags: 18
1/0: inf
0/0: Invalid operation
Overflow (5*10^308): inf
Underflow (10^-308/10000): Floating point underflow
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Console.WriteLine("--- Default Behavior (No Errors Raised) ---")
      Console.WriteLine($"1/0: {uc.EvalStr("1/0")}")
      Console.WriteLine($"0/0: {uc.EvalStr("0/0")}")
      Console.WriteLine($"Overflow (5*10^308): {uc.EvalStr("5*10^308")}")
      Console.WriteLine($"Underflow (10^-308/10000): {uc.EvalStr("10^-308/10000")}")
      
      Console.WriteLine("")
      Console.WriteLine("--- Enable Invalid Operation & Underflow ---")
      '// You can pass multiple enum members to enable them simultaneously
      uc.Error.SetFloatingPointErrorsToTrap(ErrorCode.FloatInvalid, ErrorCode.FloatUnderflow)
      Console.WriteLine($"Current flags: {uc.Error.FloatingPointErrorsToTrap}") '// Should be 16 (Invalid) + 2 (Underflow) = 18
      
      Console.WriteLine($"1/0: {uc.EvalStr("1/0")}") '// Not enabled, returns inf
      Console.WriteLine($"0/0: {uc.EvalStr("0/0")}") '// Enabled, raises error
      Console.WriteLine($"Overflow (5*10^308): {uc.EvalStr("5*10^308")}") '// Not enabled, returns inf
      Console.WriteLine($"Underflow (10^-308/10000): {uc.EvalStr("10^-308/10000")}") '// Enabled, raises error
   End Sub
End Module
				
			
--- Default Behavior (No Errors Raised) ---
1/0: inf
0/0: nan
Overflow (5*10^308): inf
Underflow (10^-308/10000): 0

--- Enable Invalid Operation & Underflow ---
Current flags: 18
1/0: inf
0/0: Invalid operation
Overflow (5*10^308): inf
Underflow (10^-308/10000): Floating point underflow