Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I don't know that much about binary calculations, but doesnt the transition from 4*8bits to one binary number require conversion to string first?
-
mrsulfat2956y@DevForTheMoney no necessarily ex in c you could bit swift them in and out in the order you want
-
I always sketch stuff like this instead of participating on history class etc as well
:D -
I never looked at storing array elements in this way. This is quite interesting!
-
I'm actually a bit shocked that this is seems to be something new for many of you. Shouldn't be some basics about memory representation and interpretation common knowledge amongst developers. I'm aware that not all of you have degrees and some are just starting to learn, but still.
-
Finally found it! https://advanced-ict.info/interacti...
now you can play it online! -
@AlgoRythm efficiency depends on how you intend to use it. If you access it by pixel the compiler will store each pixel at its own byte and it takes 8 times the space it does now. Yet you can force it to be stored in a single integer but if you access a pixel then the compiler will insert code that extracts the pixel from the byte it is stored in (you can't access less than a byte). So all you can do with this method is trading CPU time by memory consumption, decide wisely.
-
@JustKidding Yeah, true, but there really isn't any reason today to store characters in a single int anyways (Except for the reason "because I can"), so there isn't really any decision to make - both will perform approximately the same. Just wanted to do some science-y shit while I was bored at work.
-
actually did something like this with bitmaps that I wanted to store in an AVR chip's flash memory
-
@Milind1997 For bitmasking for example, so you can make automatic tile system.
-
Casio used a similar method to pack 5x7 bitmap characters into ten hex digits on the FX-850P. For each column (there are 5), bit 0 is ignored, bit 1 is the bottommost pixel and bit 7 is the topmost one, take a 2-digit hex of that and concat the whole thing, you've got 10 hex digits you can pass to DEFCHR$ to define *your **own** characters*! Wow!
-
deodexed5746yThere is something I don't quite get: you are storing 4 bytes of data into a 4 bytes integer, what's amazing about that ? Am I missing a revolutionary break through ?
-
@deodexed Absolutely not. It's just cool, old-school graphics, which are incredibly uncommon these days. I could have made it an array of BOOL types or something stupid (but easier) like that, but instead opted for this solution, which requires an understanding of bit operations.
-
@Root Yes! But using bits for graphics is not so obvious anymore. That's why I said "excessive", although, this was an exaggeration.
-
@JustKidding
I think it just shows how far IT has gotten in general. There are now people out there that can make a living off programming while they don't even know how computer memory works, let alone know how to manage it!
Thanks to people studying the field others won't have to, which is basically the fundamental reason were not bashing each others skulls in with rocks anymore.
Hurrah civilization? -
deodexed5746y@AlgoRythm now what astonishes me the most is the amount of people not nothing the basics
-
@DevForTheMoney seriously I think that is a really bad development. I don't say that we should throw away all the abstraction and still only use assembler. It is indeed good that we don't have to do it.
BUT saying that we don't need to understand the basics anymore is bullshit. When you write e.g. a web app you should have at least a coarse understanding of what happens in your browser and how that affects your system. The fact that people do things without knowing their implications is the reason for many performance and security issues.
There is a HUGE difference between throwing away deprecated knowledge and throwing away basic knowledge. What has been posted in this thread is not deprecated but basic and therefor should be known by anyone doing anything serious in this field. -
I wonder how many of those who were "shocked that not many people know this" actually understood
-
LuxARTS16636yAnd this is why you should learn a language like JavaScript to make a web interface where you paint/select the pixels and you get the uint32 value of that bitmap.
-
@LuxARTS Yes, always use odd width and height for fonts (especially for things like the T)
-
@LuxArts Because neither 5×7 nor 5x9 is 32 so neither of them would fit into a 32-bit integer.
-
LuxARTS16636y@AlgoRythm why you need to store in 32 bit? I mean, you will not use a significant less amount of memory using 4x8.
-
LuxARTS16636y@AlgoRythm @LuxARTS I mean significant to the hardware, of course if you use 5x7 you have to use 5 bytes instead of 4 bytes from 4x8 but unless you are planning to add the alphabet in a lot of languages you will not have memory problems (and I'm thinking in a cheapy 8 bit microcontroller).
-
@JustKidding But hey, how can you put that requirement on people? If developers were hired only if they had the very bare bones underlying knowledge of the language we wouldn't have nearly as many developers as we do. I know plenty of people who are amazing programmers, and who writes wonderful code, but I also know they miss some of the core concepts. Knowing how GC works or how to optimize? Sure. But storing a god damn bitmap in an integer? I can't really see where this would come in handy for a Node.js developer. And I definitely don't think any self taught developer should have to know this.
-
Mitiko63556yIf you were to send it to someone, maybe use hex or 32bit encoding or even 64bit encoding.
If you really want some compression use huffman -
@ScriptCoded
This is not even anything difficult. But it makes use of an incredibly fundamental concept, which is frickin BITS AND BYTES. Many developers don't regularily work on that level, but there is still no way any professional developer can get around being familiar with that concept at least. Also the concept that data is basically meaningless before it is interpreted is definitely elementary and since you are always working with nothing but data, that is actually useful to know when optimizing, because you can deligate a lot of information from the stored data to the interpreter of the data (which is basically compression). -
@ScriptCoded
And just the other way around, you can make data easier to be interpreted. And thus faster to use. So not at all trivial. -
@simulate I totally agree, knowing how bits and bytes work isn't trivial at all, but being a dick because some people haven't discovered a particular case isn't at all an okay thing to do.
-
@ScriptCoded First of all I can put any requirement on anyone if I feel the need to do so.
What upsets me is not the fact that some devs don't know relevant basic concepts but the mindset that they don't need to know about this because they're doing some high level things as JS.
I don't know all concepts myself either but I don't go out and shout I don't need to know how integers work because my language doesn't have types (simplified example ofc). These things are relevant, even for high level languages. Which brings me to the next point, complexity. Understanding the simple concepts is required to understand the complexity that is imposed by powerful languages. Running as JS app in Chrome seems simple but it inherits the complexity of million of lines of code. And even though you don't see them you should know they're there and you should care about them (as they will have impact on your users and on security). -
@ScriptCoded Also I'm not a dick about the fact that people don't know this but about their mindset that some of them think they don't need to know/learn this. If you think you're too good to be required some basic knowledge (hint: you never are) there isn't much respect I can show you.
-
@ScriptCoded No one is being a dick here, it is just pretty ignorant to assume you dont need to know something, when you dont understand it yet lol. I mean I know that idea myself of course (Ive been in school) but it is a really toxic attitude.
I was just surprised that this wasnt common knowledge to anyone who calls himself a programmer.
I think an elefant in the room here, and an issue that is often not really articulated among developers, is that there are actually huge differences and other challanges with low level and high level languages. They are completely different playgrounds.
It doesnt matter which one you prefer, they have completely different focusses, but they are yet entirely dependent on one another. So it never hurts to know what the other end of the table is talking about. -
@JustKidding
Sure, can't stop you from putting requirements on people...
Thing here is that you're getting upset because people haven't come up with the idea to store an array in an integer. It's like saying people are stupid for not have realized that cereal goes well with apple juice (haven't tried though). And not only that, but you can't seem to skip harassing people who's actually making a career of programming for not having a degree. -
@ScriptCoded Thats why I said that I'm aware that some of you are still learning. And I also already said that it actually upsets me that some people think they're so smart that they don't need to know basics.
Btw. this has nothing to do with having a degree. I've met people without a degree that have a really deep understanding of what's going on under the hood and also people with a degree that I wonder how they got it.
But I'm repeating myself and it seems that actually reading my comments isn't important so be free to stay in your bubble and feel being harassed ¯\_(ツ)_/¯ -
muliyul5766yEvery solution has tradeoffs. That's the beauty and curse of programming. If it's not that common to store fonts in an array of ints it doesn't mean nobody tried, it means the applications of such compression don't have much value. You could write in assembly and be super efficient but we're humans and we like abstractions.
Sure you can use pifs and have very (very) low space complexity but finding the sequence of bytes that actually represent something meaningful will take forever.
pifs: https://github.com/philipl/pifs
And THAT is how you stuff a 4x8 bitmap into a single int.
random
excessive optimization