Siticone Logo
Siticone UI
DOCS
v2025.12.15
Docs Humanizer Float

Siticone Humanizer Float

The SiticoneHumanizerFloat component is a powerful formatter for double-precision floating-point numbers. It extends beyond simple decimal formatting to support scientific, engineering, binary (file size), and compact notations. It also includes robust features for unit conversion, validation (min/max), and localization.

Core Data

The primary properties for inputting data and retrieving the formatted result.

Property Type Description & Usage Example
Value double humanizer.Value = 12345.6789; The raw floating-point number to be processed. Setting this triggers a recalculation of the output string.
Humanized string lblOutput.Text = humanizer.Humanized; Read-Only. Returns the formatted string based on the current Notation and configuration settings.

Notation Styles

Control how the number is represented mathematically or visually.

Style Description Example (Value = 1500)
Standard Default decimal formatting with separators. 1,500.00
Scientific Standard scientific notation (E notation). 1.50E+003
Engineering Exponents constrained to multiples of 3. 1.50E+3
Compact Uses metric suffixes (K, M, B, T). 1.50K
Binary Uses IEC standards for digital storage (KB, MB). 1.46 KB

Precision & Rounding

Fine-tune decimal places and rounding logic.

Property Type Description & Usage Example
MaxDecimalPlaces int humanizer.MaxDecimalPlaces = 4; The maximum number of digits allowed after the decimal separator.
TrimTrailingZeros bool humanizer.TrimTrailingZeros = true; If true, removes insignificant zeros (e.g., "1.500" becomes "1.5").
RoundingMode RoundingModeEx humanizer.RoundingMode = RoundingModeEx.HalfUp; Controls rounding behavior. Options: HalfUp, HalfEven, Truncate, Ceiling, Floor, SignificantDigits.

Quick Access Properties

Read-only properties to get specific formats instantly without changing the global state.

Property Type Description
CompactNotation string Returns the value formatted with metric suffixes (K, M, B).
BinaryNotation string Returns the value formatted as a file size (B, KB, MB, GB).
CurrencyNotation string Returns the value formatted as currency based on CurrencyCode.
PercentageNotation string Returns the value as a percentage (Value * 100).
HexadecimalNotation string Returns the integer part of the value in Hex format (e.g., 0xFF).

Validation & Logic

Ensure data integrity by enforcing limits.

Property Type Description & Usage Example
MinimumValue double? humanizer.MinimumValue = 0; Sets a lower bound. Setting Value below this throws an exception.
MaximumValue double? humanizer.MaximumValue = 100; Sets an upper bound for the allowed value.
Epsilon double humanizer.Epsilon = 0.0001; Tolerance value for zero comparisons (avoids floating point errors).

Public Methods

Utilities for unit conversion and normalization.

Methods
// Add a custom conversion unit
humanizer.AddCustomUnit("Meter", 1.0);
humanizer.AddCustomUnit("Kilometer", 1000.0);

// Convert current Value to a target unit
double kmValue = humanizer.ConvertTo("Kilometer");

// Normalize Value within a range (returns 0.0 to 1.0)
double progress = humanizer.Normalize(min: 0, max: 100);

// Get string using immediate settings without affecting the component
string result = humanizer.Humanize(9876.54);

Designer & Smart Tags

Integrated design-time tools for rapid configuration.

Feature Category Capabilities
Value Presets Quickly set Value to common test numbers: Zero, Small, Million, Billion, Negative.
Format Options View Current Format: Preview the output string.
Preview All Formats: Opens a dialog showing the value formatted in all available notations.
Set Decimal Places: Quick configuration for precision.
Actions Copy Humanized Value: Copy the output string to clipboard.
Copy/Paste Settings: Transfer configuration between components.

Detailed Usage Examples

Example 1: File Size Formatter

Displaying file sizes in KB, MB, GB using Binary notation.

C# - File Size Logic
private void DisplayFileSize(long bytes)
{
    humanizerFloat.Value = bytes;
    humanizerFloat.Notation = SiticoneHumanizerFloat.NotationStyle.Binary;
    humanizerFloat.MaxDecimalPlaces = 2;
    
    lblSize.Text = humanizerFloat.Humanized;
                // Output examples: "500 B", "1.52 MB", "4.20 GB"
}

Example 2: Scientific Data Display

Formatting measurements with scientific notation and specific rounding.

C# - Scientific Data
private void ShowMeasurement(double measurement)
{
    humanizerFloat.Value = measurement;
    humanizerFloat.Notation = SiticoneHumanizerFloat.NotationStyle.Scientific;
    humanizerFloat.RoundingMode = SiticoneHumanizerFloat.RoundingModeEx.SignificantDigits;
    humanizerFloat.MaxDecimalPlaces = 4;
    
    lblResult.Text = humanizerFloat.Humanized;
                // Output: "1.2345E+05"
}

Example 3: Currency & Localization

Formatting financial values for specific regions.

C# - Currency Logic
private void UpdatePrice(double price)
{
    humanizerFloat.Value = price;
    humanizerFloat.UseCurrencyFormat = true;
    humanizerFloat.CurrencyCode = "EUR";
    humanizerFloat.Culture = new CultureInfo("de-DE");
    
                // Or access the quick property directly
    lblPrice.Text = humanizerFloat.CurrencyNotation;
                // Output: "1.250,50 €" (depending on culture settings)
}