2

I'm using a velocity template in my Scala app which logs to a file. If I'm dividing by zero why do I get a unicode representation (∞) in my templated log file and Infinity printed on Eclipse console when debugging the below code?

val params = MMap.empty[String, Any]
params.put("percent", ((23.6 * 100.0) / 0.0))
debug(params.get("percent")).toDouble + "")
212
  • 915
  • 3
  • 9
  • 19

1 Answers1

2

Probably because this character is U+221E INFINITY, i.e. , i.e. the infinity sign?


As to where it comes from, well, it's unlikely that it comes from Scala itself. I've taken the liberty to d/l the current master and search for 221e, 221E, , 8734 and even Infinity. I've found nothing indicative of such a conversion.


There's a simple solution for finding what does the conversion (and this is general for such problems):

  • run your app with debugger access (for externally started JVMs you need debug mode with suspend=y preferably),
  • put a breakpoint on that debug statement,
  • step through until you find the offending code.
Community
  • 1
  • 1
mikołak
  • 9,605
  • 1
  • 48
  • 70