Found this gem yesterday...

function justNumber(BigDecimal n) {
  string negative_sign = "-";
  BigDecimal response = BigDecimal.valueOf(n.toString().replace(negative_sign, ""));
  return response;

  • 0
  • 1
  • 3
    I mean u can subtract the number from zero if it has negative sign to get it positive but this my sir is a masterpiece indeed ..
  • 2
    Nice naming of the function, like "-" is irrelevant for numbers
  • 7
    Looks like an npm dependancy for the 'negative-just-number' package.
  • 5
  • 3
    @fonz No. That would be too simple. This guy got paid by lines.
  • 1
    I was now just wondering what would be the fastest implementation of an absolute function. Naive implementation is if smaller zero, times negative 1. Wonder if something like that would work on big decimals and if it were faster: n << >>
  • 1
    What the actual, razor-flinging fuck.
    This deserves some kind of award for the most useless code ever.
  • 1
    Doesn’t look like ruby
  • 1
    I can't decide if more upset by the string replace or that long ass redundant variable...
  • 1
    ... wow.
  • 6
    Tagged Java, uses keyword 'function'

  • 1
    @Commodore I have good news, you can have both! I am enraged by all of these things and more. :)
  • 0
    This is really funny. LOL
Your Job Suck?
Get a Better Job
Add Comment