35

(Actually a dupe of another question but that was incorrectly closed so I’m posting here until the other question gets reopened, and this one merged.)

This has bugged me for ages. The website uses hyphens in negative numbers throughout. It should use the minus sign instead.

Of course it’s not important. It just looks really ugly.

The new reputation reporting tracker (thumbs up!) makes this particularly obvious:

wrong
right

Jin and waffles say on the other thread that for the SO font, the dash actually looks better than the minus sign but I think they made a mistake: They might have used the en-dash accidentally, which does indeed look even worse than the hyphen here.

15
  • 9
    Obligatory XKCD reference for this kind of discussions: xkcd.com/1015
    – sbi
    Commented Mar 2, 2012 at 10:10
  • 4
    @sbi Has a point, this only bugs people who actually notice it. But those, it bugs hard. I can’t mentally “switch off” noticing bad typography. Commented Mar 2, 2012 at 10:12
  • Actually, my immediate thought was "What happens if I copy & paste those numbers into a spreadsheet program?" I suppose Excel will not be able to tell that a "—" (em-dash) is supposed to be a "-" (minus). Therefore I upvoted this question.
    – sbi
    Commented Mar 2, 2012 at 10:17
  • @sbi Wow, Excel sucks. :D I’ve tried it, it recognises neither dashes nor the Unicode minus sign U+2212 Commented Mar 2, 2012 at 10:20
  • 1
    "I suppose Excel will not be able to..." I haven't tried. Maybe it does. From a programmer's POV, it's still the wrong char, though. And I'm a programmer on a programmers' website. :)
    – sbi
    Commented Mar 2, 2012 at 10:22
  • 4
    Facetious comment first: since a hyphen is not part of the numerical representation of a number, all the supposed negative numbers on this site are actually positive! This means that we need a massive rep recalc whereby all down-votes are actually counted positively. Commented Mar 2, 2012 at 10:30
  • 10
    Serious comment second: Forget Excel, I wonder how screen readers deal with this. Do they read "hyphen ten"? How is one supposed to know that that means minus ten? Commented Mar 2, 2012 at 10:31
  • 1
    Is it actually 'wrong', given that the character is named HYPHEN-MINUS and "used for either hyphen or minus sign" ? (this is a serious question)
    – AakashM
    Commented Mar 2, 2012 at 10:50
  • 6
    @AakashM Typographically, yes, it’s wrong. There can be no question – it’s simply rendered as a hyphen and those two characters are rendered completely different. The important point is that it doesn’t match the plus sign. The Unicode standard simply takes a realistic stance: since the hyphen has been in existence on typewriters much longer and the minus sign isn’t on any keyboard, it is entirely acceptable not to require a convoluted action to type the “correct” character. But this argument doesn’t apply here since the number display is generated by a software, not a person typing them. Commented Mar 2, 2012 at 11:09
  • 1
    Forgive my ignorance, but what's the difference between a hyphen and a minus sign? I thought they were the same character. I know what an em-dash and an en-dash are, but I thought the - next to my equals sign was the same as the - in my number pad Commented Mar 9, 2012 at 21:46
  • @Jon - However, in environments that are restricted to ISO 646, and often in computing generally, the hyphen is represented by a hyphen-minus ( - ), which is well known and easy to enter on keyboards. so under what circumstances will there actually be a difference between a hyphen and a minus sign Commented Mar 9, 2012 at 21:58
  • 1
    @Adam: Oops. Misread the comment. That I don't know. Nothing? Commented Mar 9, 2012 at 21:59
  • 2
    @Adam The “minus” on your numblock isn’t a minus, it’s also the hyphen. However, there is a separate character (which is not available on common keyboard layouts) for a minus sign which renders subtly but fundamentally different: it is on the same height, and has the same width, as the “+” sign of the same font. Contrast this with the hyphen (just look at my screenshots). Once you know what the difference is, the wrong character becomes a jarring annoyance. Commented Mar 10, 2012 at 0:59
  • 6
    +1 Full ack. Just because lots of people don't care or can't tell doesn't mean we shouldn't be doing it right, especially if it's such a simple thing to get right.
    – Kerrek SB
    Commented Apr 8, 2012 at 21:53
  • 1
    Related question (TeX Meta): Use dashes in page titles instead of hyphens, and still somewhat related (MSE): Strange punctuation in "Congrats, you've gained the privilege" message
    – doncherry
    Commented Apr 9, 2012 at 0:00

2 Answers 2

1

We won't be changing this, it adds way too much complexity to code that does something very, very simple...for very little benefit.

10
  • 15
    Not that I can see your code or anything, but... what does this have to do with code complexity? Could you be, perhaps, misunderstanding the question? From what I read, it's just using one character in place of another. Commented Mar 9, 2012 at 21:21
  • 2
    @Jon = thisIsANegativeIntergerVariable.ToString() is effectively what happens, the literal code is @re.RepChange, that's it.
    – Nick Craver Mod
    Commented Mar 9, 2012 at 21:27
  • 12
    Now I'm really confused. Are you saying that some library's ToString() function outputs a dash as opposed to a minus sign for negative numbers? If so, that's a bug in the library, I'd say. Commented Mar 9, 2012 at 21:41
  • 7
    @JonEricson - this is default razor view behavior, feel free to file a bug with Microsoft :)
    – Nick Craver Mod
    Commented Mar 9, 2012 at 21:41
  • 4
    Stepping off my high horse now... Ugh. That's truly annoying and I feel your pain. (Thanks for indulging my curiosity.) Commented Mar 9, 2012 at 21:44
  • 3
    GAHH!!! Is this a dash, or a hyphen? Is Razor spitting out negative numbers with an em-dash, an en-dash, or a hyphen? The question, and coments all seem to use them interchangeably. Commented Mar 9, 2012 at 22:04
  • 9
    So what you’re saying is effectively that you only have to replace x.ToString() with x.TypographicallyCorrectToString(), given an extension method which performs return x < 0 ? '\u2212' + Math.Abs(x).ToString() : x.ToString()? – EDIT I just see that, no, it’s not. It would at least necessitate patching the library. Well, I’m off to file a bug report then. It’s what I do today. Commented Mar 10, 2012 at 0:45
  • Did anything happen in the meantime? Commented Jan 8, 2015 at 15:09
  • 5
    Well this has 254 votes on MSO as of this comment
    – durron597
    Commented Mar 4, 2016 at 4:14
  • 2
    @MartinUeding yes, 10 years passed. Commented May 28, 2022 at 7:36
11

I’ll note that the recent achievements pop-up already uses true minus signs for reputation changes instead of hyphens.

Though this alone may not be enough to compel you to switch, Codidact doesn’t have this problem.

Here’s a userscript. The initial version took me about half an hour to write, so it did not require very much effort at all (and I am at a disadvantage in that I cannot easily identify every place where a negative value can appear, and fixing it up after-the-fact in the DOM adds considerable overhead; doing this server-side would be simpler and cleaner). This was easy to do. All it takes is some political will.

// ==UserScript==
// @name     Stack Exchange: minus signs
// @grant    none
// @run-at   document-start
// @match    https://*.stackexchange.com/*
// @match    https://*.superuser.com/*
// @match    https://*.stackoverflow.com/*
// @match    https://*.mathoverflow.net/*
// @match    https://*.serverfault.com/*
// @match    https://*.askubuntu.com/*
// @match    https://stackapps.com/*
// @exclude  https://api.stackexchange.com/*
// @exclude  https://data.stackexchange.com/*
// @exclude  https://openid.stackexchange.com/*
// @exclude  https://contests.stackoverflow.com/*
// @exclude  /^https?:\/\/winterbash\d{4,}\.stackexchange\.com\//
// ==/UserScript==

const SELECTOR = `
  .rep-down,
  .ob-post-votes,
  .js-vote-count,
  .js-vote-count > *,
  .js-discussion-score,
  .js-discussion-score > *,
  .mini-counts,
  .mini-counts > :only-child,
  .answer-votes,
  .js-metadata-vote-count,
  .s-activity-indicator,
  .s-post-summary--stats-item,
  .s-post-summary--stats-item-number,
  .s-badge,
  .s-badge > span:only-child,
  .js-followed-post .fs-body3,
  .vote-count-post,
  .vote-count-post > :only-child,
  .flex--item > div,
  .vote,
  .-stats,
  .movedDown,
  .bounty-indicator-tab,
  td.event-comment > span > span,
  .slick-cell.number
`;

const replaceHyphen = (obj, prop) => {
  const oldValue = `${obj[prop]}`;
  const newValue = oldValue.replace(/(?<=^|\s|[\[\(])\u002d(?=\d)/gu, '\u2212');
  if (oldValue !== newValue)
    obj[prop] = newValue;
};

const fixupNode = node => {
  if (!node.matches(SELECTOR))
    return;
  if (node.title)
    replaceHyphen(node, 'title');
  if (node.firstChild?.nodeType === document.TEXT_NODE)
    replaceHyphen(node.firstChild, 'data');
};

const fixupUnder = node => {
  fixupNode(node);
  for (const subnode of node.querySelectorAll(SELECTOR))
    fixupNode(subnode);
}

if (document.body)
  fixupUnder(document.body);

new MutationObserver(mutations => {
  for (const mut of mutations) {
    switch (mut.type) {
      case 'characterData':
        fixupNode(mut.target.parentNode);
        break;
      case 'attributes':
        fixupNode(mut.target);
        break;
      case 'childList':
        fixupUnder(mut.target);
        break;
    }
  }
}).observe(document, {
  childList: true,
  attributes: true,
  attributeFilter: ['title'],
  characterData: true,
  subtree: true,
});
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .