Notes for December 11, 2020
I didn’t have much time to log content today, so I’ll only be covering 2 major topics:
- JS Numbers and Rounding
- MIT coursework I’d like to retake
JS Numbers
I need to get reacquainted with floating points and their implementation
- https://stackoverflow.com/questions/588004/is-floating-point-math-broken/27030789#27030789
- https://stackoverflow.com/questions/1458633/how-to-deal-with-floating-point-number-precision-in-javascript
I would probably focus on Javascript and maybe C to give me an idea of low-level details. I remember the good old days in school when I used Java and had a deeper understanding of types and their implementation….
There was a good quote from one of the above, or maybe even a different article. Paraphrasing, programmers are confused when 0.1 causes issues (1/10), but they don’t flinch at the site of 1/3 being represented as .33333333….
The part where I disagree with this is the fact that in JS, if you set a variable as .1, nothing happens, it looks and acts like .1. If I add .1+.1 things are still fine. But only when I add .1+.2 then strange things happen. If there is truly something wrong with .1 then adding .05+.05 should also give me issues, but it doesn’t. Can you imagine if if 1/3 didn’t give me issues, 1/6 + 1/6 didn’t give me issues, but 1/3 + 2/3 gave me 1.0000000000003? That’s the real confusion here.
JS Rounding
I found out today that the usual method I use for rounding a number to a certain number of decimal points toFixed returns a string. There are reasons for this, but this is annoying when I need a number. Math.round returns a number, but that can only round to the nearest integer, not to a specific decimal point. See this stackoverflow for one way to handle this by rounding a division and multiplication by a power of ten, eg. Math.round( someNumber * 1e2 ) / 1e2
There are probably more idiomatic ways to handle proper decimal points in JS that I haven’t explored, i.e. some library that is as standard as lodash.
One of the comments in the article above mentions that prefixing an expression with + will basically do a type conversion to number, eg. +(someNumber.toFixed(2) could also work.
MIT Coursework
I’ve been wanting to restart an MIT course that I didn’t do well in. I am currently eyeing something that I was good at but didn’t invest enough time in, 6.033, or something that I failed at, 6.003.
- http://web.mit.edu/6.033/2017/wwwdocs/
- http://web.mit.edu/6.033/www/general.shtml
- http://web.mit.edu/6.033/2011/wwwdocs/schedule.shtml (the year I took it with Butler Lampson)
- https://ocw.mit.edu/resources/res-6-004-principles-of-computer-system-design-an-introduction-spring-2009/online-textbook/
- https://ocw.mit.edu/courses/physics/
- https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-172-performance-engineering-of-software-systems-fall-2018/index.htm?utm_source=OCWHomePage&utm_medium=CarouselSm&utm_campaign=FeaturedCourse
- http://web.mit.edu/6.033/lec/
- https://sigproc.mit.edu/fall20/software/installing/gnu_linux
I never took 172, but that performance class is probably the best introduction to low-level computing, something that I’ve been lacking. Rather than taking a systems course, or taking an OS course when I don’t program operating systems, I am having thoughts that 172 is a more practical C-language, low-level course.
I will make a decision and commit to a class in 2021, as I want to end 2020 by re-starting the nanocourse on self-driving cars.