I want to display a negative symbol from a string in .NET. I want a string that represents an equation that looks something like this:
7--5=12
But when displayed, I want the 2nd minus sign to be slightly raised so it looks more natural as a negative sign instead of just 2 minus signs in a row.
Is this possible?
Type the following key combination : ⌥ Alt + ⇧ Shift + = : ± The technique: Keep the Alt ⌥ and ⇧ Shift keys pressed, then type on the key = , which will bring up the "plus or minus" sign : ± at the desired location.
Not sure if theres a character for what you want but a simple solution (and one that would be easily understood and implemented) would be to surround your negative number in brackets:
7 - (-5) = 13
Use the Unicode character SUPERSCRIPT MINUS (U+207B)
⁻
.
For example:
7-⁻5 = 13
EDIT: Or, with a MINUS SIGN (U+2212)
⁻
for the minus:
7 − ⁻5 = 13
Provided that you're using unicode you can use a true minus sign, "−" (U+2212) rather than a hyphen-minus, "-" (U+002D). Just be aware that it's not ASCII compatible
Here's your example showing them:
7 - −5=13
Also, here's some fun wiki-articles on all sorts of dash-hyphen-minus lines: http://en.wikipedia.org/wiki/Dash#Common_dashes http://en.wikipedia.org/wiki/Minus_sign#Character_codes
This is a great resource on format strings in C#: SteveX Compiled - Format Strings
You can choose how a negative number is displayed by using a range expression for your format string. It's in the format:
{0:<PositiveFormat>;<NegativeFormat>;<ZeroFormat>}
For example, this is how to display a negative number in parenthesis and the word "Zero" for 0:
{0:#;(#);Zero}
Using this technique, I think you can try it with the superscript version of negative (which is ascii code U+207B) in the negative format string.
{0:#;⁻#;Zero}
HTH, Anderson
Traditionally in math typography you use an en dash U+2013 or minus U+2212 (but not a hyphen!) for both binary (subtraction) and unary (negation) minus, and they are differentiated with spacing (spaces before and after a binary minus, no space between a unary minus and the number it negates).
But if you want to further distinguish the unary, I'd recommend substituting the superscript minus U+207B (but keep the spacing around the subtraction minus):
7 − ⁻5 = 13
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With