DEV Community

Michael Brackett
Michael Brackett

Posted on

1

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!

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay