# Enumerations (for Customization)

## Overview

The Enumerations for Customization in the SiticoneHumanizerFloat control include two key enums: one for specifying the rounding mode (RoundingModeEx) and another for defining the notation style (NotationStyle). These enumerations provide developers with a straightforward way to tailor the behavior of numeric formatting and representation. The RoundingModeEx enumeration allows for fine control over how numbers are rounded, while the NotationStyle enumeration determines the style in which numbers are formatted (e.g., Standard, Scientific, Engineering, Compact, Binary).

***

### Key Points

<table data-full-width="false"><thead><tr><th width="185">Item</th><th>Description</th></tr></thead><tbody><tr><td>RoundingModeEx</td><td>An enum that defines rounding behaviors, including HalfUp, HalfEven, Truncate, Ceiling, Floor, and SignificantDigits.</td></tr><tr><td>NotationStyle</td><td>An enum that specifies the formatting style, including Standard, Scientific, Engineering, Compact, and Binary.</td></tr></tbody></table>

***

### Best Practices

<table><thead><tr><th width="321">Aspect</th><th>Recommendation</th></tr></thead><tbody><tr><td>Select Appropriate Rounding Mode</td><td>Choose a rounding mode that aligns with your application's precision requirements; for example, use HalfUp for financial calculations and SignificantDigits for high-precision scientific computations.</td></tr><tr><td>Match Notation to Context</td><td>Use NotationStyle that best fits the data context (e.g., Scientific for extreme values, Compact for summarizing large numbers on dashboards).</td></tr><tr><td>Consistent Usage Across Application</td><td>Apply these enums consistently across different parts of your application to maintain a unified numeric presentation.</td></tr></tbody></table>

***

### Common Pitfalls

| Issue                             | Description                                                                                                                  | Resolution                                                                                                                       |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Incorrect Rounding Mode Selection | Selecting a rounding mode that does not match the application's logic may result in unexpected numeric values.               | Test each rounding mode with representative values to verify the outcome aligns with the business requirements.                  |
| Inconsistent NotationStyle Usage  | Using different notation styles in various parts of the application may confuse users and lead to inconsistent data display. | Standardize the notation style across the application and document the rationale behind the chosen style.                        |
| Overlooking Edge Cases            | Some numeric edge cases (e.g., very small or large numbers) may not be displayed as expected with the default enum settings. | Conduct thorough testing with a wide range of numeric inputs to ensure that the selected enum values provide the desired output. |

***

### Usage Scenarios

<table><thead><tr><th width="256">Scenario</th><th>Description</th></tr></thead><tbody><tr><td>Financial Applications</td><td>Use RoundingModeEx.HalfUp with NotationStyle.Standard to ensure currency values are rounded and displayed in a conventional format.</td></tr><tr><td>Scientific Data Presentation</td><td>Apply RoundingModeEx.SignificantDigits along with NotationStyle.Scientific to accurately represent very large or small numbers.</td></tr><tr><td>Dashboard Reporting</td><td>Combine NotationStyle.Compact with RoundingModeEx.Truncate to create concise summaries of large data sets for dashboards.</td></tr></tbody></table>

#### Code Example: Configuring Rounding Mode and Notation Style

```csharp
// Create an instance of the humanizer control
var humanizer = new SiticoneHumanizerFloat();

// Set the rounding mode to HalfUp for standard rounding
humanizer.RoundingMode = SiticoneHumanizerFloat.RoundingModeEx.HalfUp;

// Set the notation style to Standard
humanizer.Notation = SiticoneHumanizerFloat.NotationStyle.Standard;

// Assign a sample value
humanizer.Value = 12345.6789;

// Display the humanized value based on the selected enums
Console.WriteLine("Standard Format: " + humanizer.Humanized);
```

#### Code Example: Scientific Notation with Significant Digits

```csharp
// Create an instance of the humanizer control
var scientificHumanizer = new SiticoneHumanizerFloat();

// Set the rounding mode to SignificantDigits for precise control
scientificHumanizer.RoundingMode = SiticoneHumanizerFloat.RoundingModeEx.SignificantDigits;

// Set the notation style to Scientific for exponential representation
scientificHumanizer.Notation = SiticoneHumanizerFloat.NotationStyle.Scientific;

// Assign a sample value
scientificHumanizer.Value = 0.00012345;

// Display the value in scientific notation
Console.WriteLine("Scientific Format: " + scientificHumanizer.Humanized);
```

***

### Real Life Usage Scenarios

<table><thead><tr><th width="298">Scenario</th><th>Description</th></tr></thead><tbody><tr><td>International Banking Systems</td><td>RoundingModeEx.HalfUp combined with NotationStyle.Standard ensures that all financial figures are rounded and displayed consistently for audit purposes.</td></tr><tr><td>Environmental Data Analysis</td><td>RoundingModeEx.SignificantDigits along with NotationStyle.Engineering can be used to represent sensor measurements accurately in engineering contexts.</td></tr><tr><td>Web-Based Analytics Dashboards</td><td>NotationStyle.Compact provides a simplified view of large numbers on dashboards, improving readability for end users.</td></tr></tbody></table>

#### Code Example: Dashboard Integration

```csharp
// Example: Configuring a dashboard display using compact notation
var dashboardHumanizer = new SiticoneHumanizerFloat
{
    // Use Compact notation for a concise display of large numbers
    Notation = SiticoneHumanizerFloat.NotationStyle.Compact,
    // Set rounding mode to Truncate to simplify displayed values
    RoundingMode = SiticoneHumanizerFloat.RoundingModeEx.Truncate,
    MaxDecimalPlaces = 2,
    UseThousandsSeparator = true
};

dashboardHumanizer.Value = 987654321;
Console.WriteLine("Dashboard Format: " + dashboardHumanizer.Humanized);
// Expected output might be a compact form like "987.65M" depending on the custom suffix settings.
```

***

### Troubleshooting Tips

| Issue                     | Possible Cause                                                                                  | Suggested Action                                                                                             |
| ------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Inaccurate Rounding       | The selected RoundingMode may not suit the numeric data being processed.                        | Verify the output by testing with various numeric values and adjust the RoundingMode if necessary.           |
| Confusing Notation Output | Using NotationStyle that doesn't match the context can lead to confusing or cluttered displays. | Experiment with different NotationStyle values and choose the one that provides the clearest representation. |
| Edge Case Handling        | Extreme values may not display correctly if the enums are not tested thoroughly.                | Test edge cases (very small or large numbers) and adjust the formatting properties or enums accordingly.     |

***

### Review

<table><thead><tr><th width="229">Aspect</th><th>Review Notes</th></tr></thead><tbody><tr><td>Customization Flexibility</td><td>The enumerations offer robust customization options that allow developers to fine-tune how numbers are displayed and rounded.</td></tr><tr><td>Ease of Implementation</td><td>The use of clear enum names and values makes it easy to integrate and understand the impact of each setting.</td></tr><tr><td>Potential Issues</td><td>Developers must carefully select the appropriate enum values to avoid unintended behavior, especially with edge cases.</td></tr><tr><td>Integration Consistency</td><td>Consistent use of these enums across the application enhances data presentation and overall user experience.</td></tr></tbody></table>

***

### Summary

<table><thead><tr><th width="250">Summary Point</th><th>Description</th></tr></thead><tbody><tr><td>Precise Rounding Control</td><td>RoundingModeEx enables developers to choose from multiple rounding strategies to meet specific precision requirements.</td></tr><tr><td>Versatile Display Options</td><td>NotationStyle offers various formats, such as Standard, Scientific, Engineering, Compact, and Binary, to suit different use cases.</td></tr><tr><td>Streamlined Customization</td><td>Enumerations simplify the configuration of numeric display settings, allowing for consistent and maintainable code.</td></tr><tr><td>Enhanced User Experience</td><td>Properly configured enums ensure that numerical data is presented clearly and accurately, improving user comprehension.</td></tr></tbody></table>

***

### Additional Considerations

<table><thead><tr><th width="290">Consideration</th><th>Description</th></tr></thead><tbody><tr><td>Documentation of Enum Choices</td><td>Clearly document which enum values are most appropriate for specific application scenarios to assist future developers.</td></tr><tr><td>Testing Across Data Sets</td><td>Test the numeric formatting across a variety of values to ensure that the chosen enum settings work well in all scenarios.</td></tr><tr><td>Future Enhancements</td><td>Consider adding additional enum values if new rounding strategies or notation styles are required by evolving application needs.</td></tr></tbody></table>

#### Code Example: Comprehensive Exception Handling with Enums

```csharp
try
{
    // Example: Setting an unsupported enum value (this scenario is unlikely if using defined enums, but serves as a guard)
    humanizer.RoundingMode = (SiticoneHumanizerFloat.RoundingModeEx)999;
}
catch (ArgumentException ex)
{
    Console.WriteLine("Invalid rounding mode: " + ex.Message);
}
```

***

By leveraging the Enumerations (for Customization) in the SiticoneHumanizerFloat control, developers can fine-tune numeric formatting and rounding to suit a wide range of application scenarios. The clear and intuitive enum options simplify the integration process, ensuring that numbers are presented in a consistent, user-friendly manner across .NET WinForms applications.
