Ran across this blog post which was confused about how .NET’s Math.Round does rounding (especially back in 1.x).  Specifically, when the number happens to be x.5 (1.5, 2.5, 3.5, etc.) it rounds to the nearest even number.

A couple things to note:

1) This behavior has been in previous languages (for instance, VBScript, which obviously has some age on it)
2) Even outside of other languages, the method has been around for awhile – it’s called banker’s rounding

Advertisements

del.icio.us bookmarks for the week ending January 28, 2006

Bookmarks added by del.icio.us user jmanning between January 22, 2006 and January 28, 2006

progress in a console window… and it works in 1.x too

BradA did a post for progress in a console window awhile back with a C# sample using one of the new Whidbey API’s in the Console class – Console.SetCursorPosition.  That’s great, but as any tty user should be able to tell you, the simplest method for getting your cursor back a character isn’t explicitly setting the position (like Brad does) or using \r to carriage-return back to the start of the current line and then print the same line with the last character changed (like one of the comments says), but it’s instead \b (aka ^H (do those jokes make more sense now?), ascii 8, etc.) which will quite nicely back up a single character.  KISS, ya know.

I added a Thread.Sleep in the Main loop (so you can actually see it) and took out the ctor for the spinner class (it was useless, might as well let the compiler generate the ctor if it’s going to only do that).  It keeps an index into an array of chars now instead of a switch statement, so it’ll be easier to change which characters you want to use for your particular spinner (the comments on his blog post show others have their own preferences).

using System;
using 
System.Threading;

class Program
{
    
static void Main(string[] args)
    {
        ConsoleSpinner spin 
= new ConsoleSpinner();
        
Console.Write(“Working…. “);
        while 
(true)
        {
            spin.Turn()
;
            
Thread.Sleep(1000);
        
}
    }
}

public class ConsoleSpinner
{
    
int index 0;
    static readonly char
[] spinChars = new char[] {
            
‘/’‘-‘‘\\’‘-‘,
        }
;

    public void Turn()
    {
        Console.Write(
‘\b’);
        
Console.Write(spinChars[index]);
        
index (index + 1) % spinChars.Length;
    
}
}

del.icio.us bookmarks for the week ending January 21, 2006

Bookmarks added by del.icio.us user jmanning between January 15, 2006 and January 21, 2006

want to know why LoadWithPartialName is deprecated?

Because Suzanne said so.  Or, well, to be more accurate, because it really was the right change to make.

23:43 [ d2d_zZzz] why the hell is Assembly.LoadWithPartialName flagged as obsolete?
23:49 [ Flav] d2d_zZzz: http://blogs.msdn.com/suzcook/archive/2003/05/30/57159.aspx

It’s exactly the kind of problem where your first thought is the wrong one – initially partial loading looks like a real time-and-effort saver and helps ease development and deployment issues.  The path to Dll Hell is paved with API’s with good intentions, after all.

picking a new theme for the blog

For awhile, I’ve been annoyed that this WordPress theme (“Rin“, slightly modified) doesn’t use the full width of my browser window.  It seemed like most themes do that – pick a certain width and stick to it, I’d imagine for reasons of “consistency” or more likely “easier to develop the theme like that than worry about scaling with width”.  I guess the fixed vs. relative debate will continue to rage, but consider me square in the “relative” camp, even if others consider that heresy.  Yes, liquid/fluid/relative (lots of names, same thing) is harder to do

I’ve been checking the entries at the WordPress 1.5 theme competition blog using their theme browser.  My requirement was something that used the full (or close to the full) width of the browser and scaled relatively well with varying widths.

I haven’t made a “final” decision as of yet, but here are the ones that made the “must scale with width” cut and the relative score I gave them (descending).

Any thoughts?  Any convincing “here’s why fixed really is the right choice” sage advice? (outside of ideal line length arguments, which I’m already familiar with.

Travelogue

Very clean, nice smoothness, 9.0

Journalized Blue/Sand/Winter

Nice layout, but a little blocky – hmm 8.5

man~ja

Nice, but a little sparse 8.5

Sharepoint like

Nice colors, clean, Category (and others) in Russian 8.5

Operate

Not bad, need to scale down the left bar 7.0

Yaaarr! Tis me blog!

Funny, decent colors, 7.0

Gentle calm

Good colors, wasted space? small font 7.0

Safety

Smooth, but iffy colors 6.0

Sixties

Too many pastels 5.0

Slashdot

Too Slashdot-like 🙂 5.0

SimpleGreen

Bad colors 4.0

anarchy

blocky, bad colors 3.0

Curtains up

blocky, bad colors 3.0

pumpkin

Bad colors 3.0

RadMod

Blocky, bad colors 3.0

WWAGS? (What Would Alan Greenspan Say… about a home equity line of credit? :)

The Federal Reserve (hey, it turns out it’s more than just Alan Greenspan!) has put up a decent overview/primer/tutorial on our friend the home equity line of credit:

    What You Should Know About Home Equity Lines of Credit

Much like Clark, they let you know at least one stark fact:

    When you open a home equity line, the transaction puts your home at risk.

They also have another, very similar, page that’s a little less on the informative side and a little more on the warning side: When Your Home Is On the Line

refinance of a home equity loan?

This “home equity loan refinancing” site is interesting insofar as it considers refi for the home equity loan.  I’ve refi’d my mortgage already, but I can’t personally imagine that it’d be worth doing a refi on a home equity loan unless the balance was very significant, given the closing (and other) costs.

The more I think about it, the home equity line of credit really is the right match, at least for my current context.  Maybe if I had to send Sarah to Harvard and knew there was a $100k+ expense coming up, I could see needing the loan, but that’s no time soon 🙂