Automatic Humanized Output
A feature that provides a human-readable, formatted string representation of the input value using suffixes based on magnitude.
Overview
The Automatic Humanized Output feature provides pre-formatted representations of a numeric value using the Humanized and HumanizedValue properties. These properties automatically apply a scaling system with suffixes such as K (thousands), M (millions), B (billions), T (trillions), Q (quadrillions), and Qa (quintillions) based on the magnitude of the number.
This feature is useful for applications where displaying large numbers in a condensed format improves readability and user experience.
Key Points
Properties Available
Humanized, HumanizedValue
Return Type
string
Purpose
Provides a human-readable version of the Value
property with automatic suffix application.
Read-Only
Yes (automatically computed based on Value
).
Default Behavior
Converts numbers ≥1000 using suffixes, keeping 2 decimal places by default.
Suffixes Used
"", "K" (thousands), "M" (millions), "B" (billions), "T" (trillions), "Q" (quadrillions), "Qa" (quintillions)
Best Practices
Use Read-Only Properties
Directly access Humanized
or HumanizedValue
instead of manually formatting numbers.
Keep Decimal Precision
Use GetHumanizedValue
when needing custom decimal precision.
Use in UI Components
Bind Humanized
to UI elements like labels to automatically display formatted values.
Large Number Handling
Ensure extremely large numbers are appropriately capped or handled based on your application needs.
Common Pitfalls
Expecting Editable Output
Humanized
and HumanizedValue
are read-only and cannot be manually set.
Assign values to Value
instead.
Using in Incorrect Contexts
Directly displaying unformatted numbers can be difficult to read.
Always retrieve the formatted output for display purposes.
Overlooking Decimal Precision
Default precision is 2 decimal places, which may not be suitable for all cases.
Use GetHumanizedValue()
for finer control.
Usage Scenarios
Displaying User-Friendly Numbers
Automatically format large numbers for better readability in UI elements.
csharp<br>var humanizer = new SiticoneHumanizerDecimal();<br>humanizer.Value = 1500m;<br>Console.WriteLine(humanizer.Humanized); // Outputs: "1.50K"<br>
Data Dashboard Metrics
Show summarized financial, analytic, or statistical data without excessive digits.
csharp<br>var humanizer = new SiticoneHumanizerDecimal();<br>humanizer.Value = 1234567m;<br>Console.WriteLine("Total Sales: " + humanizer.Humanized); // Outputs: "1.23M"<br>
Database Query Results Formatting
Convert numerical outputs from databases into readable formats in real-time.
csharp<br>var salesFigure = database.GetRevenue();<br>var humanizer = new SiticoneHumanizerDecimal { Value = salesFigure };<br>Console.WriteLine("Revenue: " + humanizer.Humanized);<br>
Real Life Usage Scenarios
Financial Transactions
Display bank balances, transaction amounts, or market values in a condensed form.
csharp<br>var balance = new SiticoneHumanizerDecimal();<br>balance.Value = 12500000m;<br>Console.WriteLine("Balance: " + balance.Humanized); // Outputs: "12.50M"<br>
Social Media Engagement
Format user statistics like follower counts, likes, or views in a more readable manner.
csharp<br>var views = new SiticoneHumanizerDecimal();<br>views.Value = 10234567m;<br>Console.WriteLine("Video Views: " + views.Humanized); // Outputs: "10.23M"<br>
System Resource Monitoring
Show memory usage, CPU load, or storage space in a user-friendly format.
csharp<br>var memoryUsage = new SiticoneHumanizerDecimal();<br>memoryUsage.Value = 8048576m;<br>Console.WriteLine("Memory Usage: " + memoryUsage.Humanized); // Outputs: "8.05M"<br>
Troubleshooting Tips
Humanized value is incorrect
Value
may not be assigned or may not be updated properly.
Ensure Value
is set correctly before retrieving Humanized
.
Unexpected decimal precision
The default precision is 2 decimal places.
Use GetHumanizedValue(decimalPlaces: X)
for custom precision.
Large numbers don’t display
Extremely high values might exceed the predefined suffix range.
Implement logic to cap or handle numbers beyond the supported range.
Review
Functionality
Automatically formats large numbers into a user-friendly representation.
Readability
Provides clear and compact numerical output using standard suffixes (K, M, B, etc.).
Integration Ease
Simple access via Humanized
or HumanizedValue
, requiring no additional formatting.
Customization
Supports additional control over decimal places and culture settings via method calls.
Summary
Purpose
Converts large numbers into human-readable formats automatically.
Key Benefit
Simplifies data display by reducing large numerical values to a more concise representation.
Ease of Use
Easily accessible via the Humanized
and HumanizedValue
properties.
Readability Improvement
Enhances data presentation, especially in UI applications and reports.
Additional Code Examples
Example 1: Basic Implementation in a Console Application
Example 2: Updating Values Dynamically in a WinForms UI
By following the detailed documentation above, developers can effectively use the Automatic Humanized Output feature in various applications, making numerical data more digestible and user-friendly.
Last updated