DEV Community

Michael Brackett
Michael Brackett

Posted on

Week 2 - Part 2

In Week two we learnt about the Binary representation of data.

I never really thought about how my integers, floating points, or anything for that matter was REALLY stored in memory (Obviously I knew they were stored in bits somehow)

It was fairly interesting to find out that Fixed-Point numbers are stored by separating the binary into two parts, one number, and one part fractional.
Here is an example - 000001.00 is decimal 1.0, and 000001.11 is decimal 1.75.

Also watching the lecture, Chris explained something that caught my attention. Sometimes you can actually just make what seemingly has to be a double, an integer! How? Well think about it like this, when a bank needs to store how much money an account has in the system, they would typically need two parts, one for the dollars then one for the cents. Which would be stored like how I explained above. But what happens if they stored the entire thing denominated in cents? That way we can just store the entire number as an integer and make it easy on ourselves & only convert it back to dollars when we need to display it on the frontend.

Floating-point numbers actually have three parts, a sign bit (to determine positive or negative number) a mantissa, than an exponent. Here is how a floating point number is interpreted:

sign mantissa * 2^exponent

The last thing I'd like to talk about is compression of images which I found particularly interesting. Specifically the idea of 'Pallettization' in which an image in stored as a sequence of multiple colours instead of storing each colour separate think of it like instead of saying

blue blue blue blue blue green green

you just said - blue 5 green 2

See how it would make it a lot better in terms of compression? I never thought about how it was stored and I found it pretty cool that that's how they do it.

Overall I think Week 2 was pretty interesting, especially the lab!

Top comments (0)