Friday, February 11, 2011

Visual Studio VB pretty listing settings

Does anyone know how to stop Visual Studio VB.NET editor from changing my beautiful scientific notation numbers into hideous decimal notation?

It seems that this is part of "Pretty Listing" (single checkbox in the options). I'd like to keep the other features of pretty listing, I just don't want to have to stare at 0.0000000000000001 when I could be looking at 1e-16

  • I don't think there's a way to do it. You could rely on the implicit CDbl() conversion in this situation:

    Dim myPrettyNumber As Double = "1E-16"
    

    Or if you just want to be able to read it more easily, add a comment:

    Dim myUglyNumber As Double = 0.0000000000000001 ' 1E-16
    
    David Rutten : Well, since I always work with Option Strict On, the implicit conversion won't kick in. Sounds like I'm screwed then. The best solution is probably defining some constants somewhere...
    MarkJ : Never never ever use implicit conversion, it's regionally aware and it means your program will only work on certain locales. In this case just use `Val("1E-16")` which is not regionally aware and will always work.
    Cory Larson : ...I was just throwing out some options -- I never claimed they were _good_ options! :)

0 comments:

Post a Comment