312 reputation
39
bio website
location
age
visits member for 2 years, 2 months
seen Dec 15 at 12:21

Aug
12
comment Knowing the range of variable types needed
@MichaelShaw it's really dependent on the framework, but from what I've seen, when you declare an sByte you partition out less memory. Since this can be dangerous when you don't know how large the number will be, sBytes can be useful in loops when you know exactly how large it can get.
Aug
8
comment Knowing the range of variable types needed
@MichaelShaw correct, the memory savings are minute, which the OP already acknowledged. You aren't adding anything to this.
Aug
7
revised Should the check correctness of a time constrained puzzle game application be done on the server side?
deleted 1 character in body
Aug
6
comment Knowing the range of variable types needed
@MichaelShaw you need to block off the memory for the int, whether it's for a scoped variable or a class. The memory savings are there either way.
Aug
6
comment Knowing the range of variable types needed
@MichaelShaw it's true that the savings are minute, but the question already took that into account.
Aug
6
revised Many Arguments in Case Classes
added 357 characters in body
Aug
6
comment Many Arguments in Case Classes
@Doval good point, but does passing in a Tuple of two strings have better performance than passing in two strings? I know the OP didn't ask about performance, but I'm wondering your take on it.
Aug
6
comment Many Arguments in Case Classes
Would you use 2 Tuples instead of 4 parameters? I would only consider it if Item 1 and 2 in the Tuple were directly related with neither representing an index/key (in which case I'd use a dictionary.)
Aug
6
answered Many Arguments in Case Classes
Aug
6
answered Should the check correctness of a time constrained puzzle game application be done on the server side?
Aug
6
revised Knowing the range of variable types needed
added 2 characters in body
Aug
6
comment Knowing the range of variable types needed
@floopdagoop it depends on the language, as Snowman said. Most have "int" default to 32 bit as it's the standard, but you can usualyl specific int16/32/64 when defining the variable. Each of these types will block off that much memory, which is "inefficient" for memory purposes, but telling the processor to hack out chunks of memory that are not it's standard size can take a bit of extra time. You just need to measure you need for extra memory with your need for faster performance. It's all about economy of scale at that point.
Aug
6
revised Knowing the range of variable types needed
added 384 characters in body
Aug
6
comment Knowing the range of variable types needed
@delnan that analogy is awful. He asked "may I use this" and I said yes. Your comments are not helping me flesh out my answer at all. If you disagree with my answer submit your own, these comments are not meant for arguments. Feel free to give a -1 for my answer. I'll still +1 yours if it makes sense.
Aug
6
awarded  Commentator
Aug
6
comment Knowing the range of variable types needed
@delnan the question itself is asking about a narrow niche. Here's an example: you have an class that has a 100 ints in it, but none of the ints will ever go above a value of 10. Every time you create an object of that class you are blocking off 32 bits per int creating 32*100=3200 bits. If you replaced those ints with sBytes you are now creating 8*100=800. You are saving 2400 bits for use anywhere else. Yes, this is a small savings, but if you have a million of these objects you can see that the savings add up.(Sorry, I accidentally hit enter and then had to edit to get the rest of this in)
Aug
6
comment Knowing the range of variable types needed
@delnan I call it out as inefficient because blocking out 32-64 bits for a value that takes up 8 bits is a waste. To say that it's not inefficient is to say that there is literally no purpose for sByte and we should always use int.
Aug
6
comment Knowing the range of variable types needed
Also, the question isn't "what makes the most sense", it's "may I use". I answered that yes, you can, and then threw in an example of one use case and then pointed out a use case where you wouldn't want to use it. What's your issue?
Aug
6
comment Knowing the range of variable types needed
@Doval his concern is imagined, since I say right in my answer that int is faster for arithmetic operation IN SOME LANGUAGES. I point that out already. He's not adding anything.
Aug
6
comment Knowing the range of variable types needed
You edited your comment after I responded, you tricky man. For me, the perfect datatype is fits the use case as closely as possible. If your value will never be out of bounds for a SByte, then an int is overkill.