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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay