SQL
I've been working with data from simulations I've run that I'm storing in a Microsoft SQL server (2008 R2). As I come across things I might want to remember in the future, I'm jotting them down for my future use and making them available here in case they help anyone else too. I am not a database administrator so there's no telling if anything here is a good or bad idea.
I ended up with a column that only had values between 0.00 and 3.00 in steps of 0.01. It was stored as float(53), which takes 8 Bytes to store. By multiplying each value by 100 and storing the values 0 to 300 in steps of 1, I could store this as a smallint instead, which only takes up 2 Bytes. However, Cast( [colName] * 100 AS smallint) did not always work. For example, for 0.59, it stored 58 instead of 59. Instead, I first added 0.00001, a number I know is smaller than the difference between any two values, so 0.59 became 0.59001. I then multiplied it by 100 to get 59.001. I then took the floor to get 59 and casted that to smallint. So all together, I did this: Cast(Floor(([colName]+0.00001)*100) AS smallint).