It got all dark outside the office and started raining about half an hour ago, so I'm sticking around until it lets up a bit before making the 0.25-0.5 mile walk home. While I'm sticking, I might as well write up what I've learned today.
I'm working with IDL, a weak-typed language, which means you don't have to specify a type, such as int, long, double, or string, when you create your variables (real computer people are probably rolling over in their cubicles at this definition; it is more complicated than I'm making it out to be (don't get the idea from this mention of rolling over in cubicles that I in any way believe computer people have no lives; it's all in good fun)).
Weak-typed languages have all sorts of benefits and problems compared to strongly-typed languages.
Today I discovered one of the problems.
I was fitting some data by changing various parameters and running a batch of scripts that took a little under two-minutes to complete, then looking at my results and trying again. About three hours in I ran into a strange trend. A certain parameter did affect my results; I had observed it do so before, and was observing it do so now; however, no matter how I varied the parameter, I got only one of two outcomes, whereas I expected a whole continuum of variation as I varied the parameter. Above a certain parameter value, I got one answer, below it, another, and, the more tests I ran, the smaller the possible value of that, well, certain value became, until at last I determined there was indeed an integer parameter value above which I got one result, below which I got a strikingly different one. This was most odd, so I typed
helpat my idl command line, and idl did its best, which was to give me a list of all the variables of which it was aware, their contents, and their current type. The parameter I was varying was a ratio of two numbers, yet it, amongst a host of other ratios, was registered as an int. That was the problem, because I was working with a ratio very close to one. Any ratio with a value between one and two was assigned the integer value one. Any ratio between two and three was truncated to two. Well, that couldn't be my fault. After all, it's a weakly-typed language -- it's responsible for such matters!
And yet, it was my fault. As soon as I asked myself why the compiler would assign this particular ratio as an int, and looked at the various parameters in the parameter file, I realized my mistake.
All the other numbers in ratio form had these annoying little decimals at the end of them. I, of course, had deleted the decimal in this ratio after changing the value. No point in leaving it in, you know? But of course that was the whole point. In order to let the computer know it's dealing with a floating-point number rather than an int, IDL allows the user to simply add a hanging decimal. Well, isn't that convenient! And now I know.
Before I conclude this post, I ought to answer a question I am sure many of you are asking yourselves. The question is as follows: I thought he was an intern, yet he knows when it gets dark outside and starts raining. Do interns have windowed offices? The answer to this question is that yes, I do work in a windowed office. There are AC pipes hanging from the ceiling. Beneath, upon, above, and about my desk are seven computer monitors (besides my own -- five CRT, three flat panel) and ten computer chassis (although a few look like they've been cannibalized). There is also a window running the width of the room. It's at the top of the wall, though, leading to the somewhat jaded comment I was privy to a few weeks ago: "there's piping in the ceiling and the window's are raised; it's either prison or a grad-student's office." That statement, of course, now proves to be false, as this office is my very own, and I am neither graduate student nor prisoner.