Click here to Skip to main content
15,895,667 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: What I want..... Pin
rjmoses28-Mar-19 0:04
professionalrjmoses28-Mar-19 0:04 
GeneralRe: What I want..... Pin
#realJSOP27-Mar-19 8:35
mve#realJSOP27-Mar-19 8:35 
GeneralRe: What I want..... Pin
Slacker00727-Mar-19 9:35
professionalSlacker00727-Mar-19 9:35 
GeneralRe: What I want..... Pin
MarkTJohnson27-Mar-19 9:47
professionalMarkTJohnson27-Mar-19 9:47 
GeneralRe: What I want..... Pin
Dean Roddey27-Mar-19 14:40
Dean Roddey27-Mar-19 14:40 
GeneralRe: What I want..... Pin
Marc Clifton27-Mar-19 14:44
mvaMarc Clifton27-Mar-19 14:44 
GeneralRe: What I want..... Pin
englebart28-Mar-19 1:55
professionalenglebart28-Mar-19 1:55 
GeneralRe: What I want..... Pin
Member 916705728-Mar-19 2:05
Member 916705728-Mar-19 2:05 
I faced a similar problem just recently. The solution was to let the compiler handle the endianness. Integers, Chars (multibyte/Unicode in that context), all work the same way in the same language.
I don't cast/convert between integers and chars because the one is numbers, the other is characters, letters. If a conversion is needed, the compiler offers conversion functions that work the same independent of the platform.
Same for data declarations, in C(++), a uint16_t is unambiguous. Across languages however, don't see how that's supposed to work. What's even the point of piping a C source file into a Delphi compiler or vise versa?
This technique naturally results in my tools behaving the same on every platform the compiler offers.

Your post reminds me on a nightmare from a coworker I fixed a while ago. He was parsing a protocol with the bytestream containing, amongst other things, integers. The protocol is LE, the system the parser's running on is LE (Windows x86-64), all things work splendidly. For 1, 2 and 4 byte-integers that is. Just cast it! And to parse 3-byte integers, he built a monster of bit shifts and whatnot.

I've replaced his horrible mess with somewhat simple code that initializes the result to 0 and then adds byte by byte multiplying it accordingly. Viola, problem solved, function is simple and works for an arbitrary number of bytes.
GeneralRe: What I want..... Pin
rjmoses28-Mar-19 2:53
professionalrjmoses28-Mar-19 2:53 
GeneralRe: What I want..... Pin
Member 916705728-Mar-19 3:05
Member 916705728-Mar-19 3:05 
GeneralRe: What I want..... Pin
Slow Eddie28-Mar-19 3:07
professionalSlow Eddie28-Mar-19 3:07 
GeneralRe: What I want..... Pin
Steve Naidamast28-Mar-19 5:10
professionalSteve Naidamast28-Mar-19 5:10 
GeneralRe: What I want..... Pin
rjmoses28-Mar-19 23:05
professionalrjmoses28-Mar-19 23:05 
GeneralRe: What I want..... Pin
Kirk 1038982128-Mar-19 8:29
Kirk 1038982128-Mar-19 8:29 
GeneralRe: What I want..... Pin
rjmoses29-Mar-19 4:35
professionalrjmoses29-Mar-19 4:35 
GeneralRe: What I want..... Pin
Kirk 1038982129-Mar-19 6:44
Kirk 1038982129-Mar-19 6:44 
QuestionYou've got to get out more... Pin
  Forogar  27-Mar-19 3:02
professional  Forogar  27-Mar-19 3:02 
AnswerRe: You've got to get out more... Pin
F-ES Sitecore27-Mar-19 3:10
professionalF-ES Sitecore27-Mar-19 3:10 
GeneralRe: You've got to get out more... Pin
dan!sh 27-Mar-19 3:34
professional dan!sh 27-Mar-19 3:34 
AnswerRe: You've got to get out more... Pin
dan!sh 27-Mar-19 3:34
professional dan!sh 27-Mar-19 3:34 
AnswerRe: You've got to get out more... Pin
User 483504727-Mar-19 3:40
User 483504727-Mar-19 3:40 
AnswerRe: You've got to get out more... Pin
Sander Rossel27-Mar-19 3:41
professionalSander Rossel27-Mar-19 3:41 
GeneralRe: You've got to get out more... Pin
  Forogar  27-Mar-19 4:06
professional  Forogar  27-Mar-19 4:06 
AnswerRe: You've got to get out more... Pin
Ron Anders27-Mar-19 3:49
Ron Anders27-Mar-19 3:49 
AnswerRe: You've got to get out more... Pin
Kornfeld Eliyahu Peter27-Mar-19 4:55
professionalKornfeld Eliyahu Peter27-Mar-19 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.