Search code examples
.netmathcomments

How would you describe math in comments?


Well as the questions says...

An equation might be more meaningful in its math-notated form than it is in code. Being able to put math in comments could improve readabibity on my projects.

In .NET btw.


Solution

  • I just use multiple lines to do it thus:

    // Work out average as:  sum (values)
    //                      --------------
    //                      count (values)
    //
    // and distance between points as:
    //           _______________________
    //          /         2            2
    //    d = \/ (x1 - x0)  + (y1 - y0)
    //
    // and the following function:
    //
    //             3     2   
    //    f(x) = ax  + bx  + cx + d
    

    No magic required for that at all. Don't you just love ASCII art?