77
cobra
7y

Found on product core code. 🤔

Comments
  • 10
    Fuck. This is sad
  • 15
    Because f(1337) is shorter than 1337F 😂
  • 5
    Holy moly that cannot be a good practice
  • 3
    !(So efficient)

    1. Multiply 1f? Wtf
    2. (float) in return? Nooooo
    3. That func name tho
  • 4
    Just (float)n
  • 5
    @Mitiko noo, just tell the compiler directly that you want float, without any conversations. 1337.1333333337F will do.
    Could imagine that your approach could lose accuracy since the number could be interpreted as double before and than be casted to float. Educated guess tho
  • 3
    My eyes! My eyes!
  • 2
    Brun in hell mother fucker srlsy 😂
  • 2
    Bwahahahahahahaha
  • 1
    B@ribchinski burn but the bro version, brun
  • 2
    I see this all the time and I've used something like:

    int i = 1;
    float f = i + 0.0F;

    Thanks to Java's smart casts for primitives, it works really well. It's short and understandable once you're used to it.

    I agree that using it at the core of such a method seems quite bad, though. But it's OK for your everyday number conversions. Just don't try this where precision is important or number overflows can happen.
  • 0
    @eeee I can agree with you, but isn't this a redundant double cast? Forget to mention that method return value was also casted to float. SonarLint was totally crazy with this class. I hate my life when I have to debug spaghetti code 😭
  • 6
    Silently change the 1.0 to 0.95 and watch 😈
Add Comment