Do a smaller object type than int exists?
I'm making a binary save-file for my game, and I actually need to save an HUGE amount of integers. Those values goes from 0 to 618, so a 2 bytes integer would be more than enough.
When I write an integer into a file using "System.IO.BinaryWriter" it occupies 4 bytes. Is there a way to use the half of it? Even because most of it are zeroes. (Maybe using a different type, I don't know...)
I know that a data type called "binary" exists, but Google doesn't really wants to help me, nor even Unity's documentation.
I would approximately reduce the weight of my files by a factor of 2, and that's a lot actually!
Answer by Barliesque · Apr 12, 2016 at 07:25 PM
You can use the "short" integer type (also known as Int16), which uses 2 bytes -- which is supported by System.IO.BinaryWriter
Answer by Jessespike · Apr 12, 2016 at 07:25 PM
Google works fine... Any search engine would work as well.
I've searched using the words "JavaScript", "JS", "UnityScript" and "Unity" since I don't use C#.
I guess the same variables exists in US as well, I wonder why I didn't think about it.
Your answer
Follow this Question
Related Questions
Save system not working 1 Answer
Convert int to binary 1 Answer
Trying to spawn enemies on only one path 1 Answer
How do I get my weapon to stop firing if the ammo <= 0 1 Answer