Похожие чаты

How do I convert this: struct color {

unsigned char alpha;
unsigned char red;
unsigned char green;
unsigned char blue;
};
to an int in C++?

19 ответов

4 просмотра

i may not answer the question but what do u mean to int isnt char already int(number)

aklil
i may not answer the question but what do u mean t...

He wants to pack the whole structure into a single int variable

Danya🔥
He wants to pack the whole structure into a single...

like alpha 4 red 5 green 6 blue 7 and the new var will hold 4567 ?

Danya🔥
No

what then?..a sum of them?

into a 32 bit int?

Depend, for RGBA unsigned color=((unsigned)R<<24)|((unsigned)G<<16)|((unsigned)B<<8|(unsigned)A;

Kuntal M
damn it is definitely easier in rust

union color struct { unsigned char alpha; unsigned char red; unsigned char green; unsigned char blue; } unsigned color; };

Parra
this is the correct way

It is not sizeof(int) * CHAR_BIT is not necessarily equals to 32

Nils- Автор вопроса
Kuntal M
into a 32 bit int?

No just a normal int

There should be macro for library. To conform format/endianess.

Daniele°
Depend, for RGBA unsigned color=((unsigned)R<<24)...

Don't do it int isn't fixed size so it can fuck things up.

Nils- Автор вопроса

Похожие вопросы

Обсуждают сегодня

@LGCYMan @JustinKKW Q/A List 1. this part confuses me on #8: "From there, a bridge between erc20 LGXY and erc20 LGXY will be out once that swap is closed." does this mean ...
Sig | LGCY | BattleVerse L1 | BitWin
1
Did @Beeker really get banned? That's ridiculous. He's one of the few left here with half a brain and you might not always like his narrative @dgb_ycagel , but he often keeps ...
Leroy Gerrits
1
async login(req: Request, res: Response, next: NextFunction): Promise<void> { try { const { errors, input } = await RequestValidator(LoginRequest, req.body...
. .
1
Anyone here suffers from unexplained aural migraines, who would be up for talking for a bit? Doesn't *have* to be aural, but I am not asking about headaches, I mean actual mi...
Martin Rys
55
hello friends. Do you know how can I learn getx? I have a software project that I should deliver it up to 5 weeks later and I need to learn firebase too. I will be thankfull
AmirHossein Razavi
15
Доброе время суток! у меня тут иноды закончились. и понял почему по сути кстит, я периодически очищаю постгрес и сентри контайнер: postgres=# DELETE FROM nodestore_node WHER...
Юсиф Насиров
9
Привет, нужен совет старших товарищей. Есть глобальная переменная var DefaultDataFolder:string; инициализируем DefaultDataFolder:='a:\_OUT\'; есть примитивная процедур...
Max Otto
14
Hello guys, I have staked Matic as stMatic via Lido nearly a year ago and recently I wanted to unstake but the platform offered me to unstake via Kyberswap for a faster trans...
Mike
7
A couple thoughts from a random internet stranger: 1. If you want this project to gain traction you cannot keep being negative. If I just came here after finding out about Kd...
Eric Wild
46
We heading to 1.1$ 🤔?
CryptoBo$$
35
Карта сайта