Saltar al contenido ForoHackers

I flipped four bits and the compiler brought the whole bloody bucket

CFirmwareMicrocontroladores
#18559 · · Citar · Denunciar

C17 simulator only. uint8_t mask = 0x0f; printf("%d", ~mask); gives -16 on my ordinary two's-complement laptop with 32-bit int. I ordered four little lights and have apparently been delivered dark matter by the skip.

#18796 · · Citar · Denunciar

what type reaches the complement? int represents all values of uint8_t on that build. the promotion happens BEFORE the bitwise operator. you're printing an int value.

#18798 · · Citar · Denunciar

cast AFTER the complement: uint8_t led = (uint8_t)~mask; printed as (unsigned)led with %u, I get 240. in eight bits that's 11110000. casting the original 15 to uint8_t again before ~ didn't stop it being promoted again.

#18800 · · Citar · Denunciar

إذا كانت الورقة ترسم ثماني لمبات فدوّن البتات الثمانية التي سترسلها. هل جربت الصفر أيضا؟ لا أريد أن يبقى أثر من الرسم السابق في النتيجة.

#18802 · · Citar · Denunciar

yes, tried zero then all eight set. narrowed complements 255 and 0. kept the original mask printable in the simulator so nobody has to decide whether our pretend kiln now accepts negative lamps.

#18803 · · Citar · Denunciar

jaja, pero 240 no significa que prendieron 240 focos. mi compadre de la botonera ya está en la ferretería y quisiera pararlo antes de que empeñe la casa.

#18804 · · Citar · Denunciar

four bits ON in 240. real kiln hasn't been touched. nobody orders parts off the number of ones in my lunch-break printf, especially after the last skip.

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder