|
Bas de page | |
---|---|
Auteur | Sujet : nombre de bits d'un nombre |
mormegil92 | comment faire pour obtenir le nombre de bit d'un entier a en C |
![]() Publicité | Posté le 30-04-2007 à 13:36:11 ![]() ![]() |
mormegil92 | par exemple 32 en base 10 s'écrit 10000 en base 2, ce qu ej evoudrais faire c'est entré a=14689753 en base 10 et que la fonction me donne le nombre de chiffre en base 2 de cet entier a
|
olivthill | En comparant par rapport à la puissance de 2 la plus proche. |
Trap D | CHAR_BIT * sizeof int
Message édité par Trap D le 30-04-2007 à 13:54:41 |
Trap D | Il n'y a pas cette formule qui donne le nombre de chiffres d'une nombre m dans une base n : ln(m)/ln(n)+1 ? |
masklinn í dag viðrar vel til loftárása |
désolé Message édité par masklinn le 30-04-2007 à 14:11:38 --------------- I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing? |
Taz bisounours-codeur | si tu peux éviter de sortir 2 ln, et que tu fais le truc simple avec des >> & c'est mieux non ? voire sans boucle ou carrément si ton processeur a ça avec un cntlwz |
red faction |
|
![]() Publicité | Posté le 01-05-2007 à 03:14:45 ![]() ![]() |
matafan | Là tu comptes le nombre de bits à 1 dans c, pas le nombre de chiffres dans la représentation binaire. |
tbp | Sans les mains, celà donne...
|
Taz bisounours-codeur |
marctes |
|
masklinn í dag viðrar vel til loftárása |
--------------- I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing? |
Taz bisounours-codeur | ça j'avais cru comprendre, mais je ne vois aucun intérêt à cette méthode ... |
0x90 → | La taille d'un entier étant fixe y'a pas franchement de raison de parler de complexité --------------- Me: Django Localization, Yogo Puzzle, Chrome Grapher, C++ Signals, Brainf*ck. |
tbp |
|
masklinn í dag viðrar vel til loftárása |
--------------- I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing? |
0x90 → |
--------------- Me: Django Localization, Yogo Puzzle, Chrome Grapher, C++ Signals, Brainf*ck. |
MagicBuzz |
Message cité 1 fois Message édité par MagicBuzz le 02-05-2007 à 13:56:26 |
matafan |
|
MagicBuzz | Ah oui effectivement.
|
0x90 → | Parcequ'en C# y'a pas de & ptêtre ? --------------- Me: Django Localization, Yogo Puzzle, Chrome Grapher, C++ Signals, Brainf*ck. |
MagicBuzz |
|
Sve@r |
Message édité par Sve@r le 04-05-2007 à 15:10:16 --------------- Vous ne pouvez pas apporter la prospérité au pauvre en la retirant au riche. |
slvn | ca aussi ca marche...c'est même plus rapide.
|
Sve@r |
Message édité par Sve@r le 05-05-2007 à 09:25:15 --------------- Vous ne pouvez pas apporter la prospérité au pauvre en la retirant au riche. |
Trap D | Allez, je participe aussi
Ne marche pas pour x = 0 . Message édité par Trap D le 04-05-2007 à 23:58:45 |
![]() Publicité | Posté le ![]() ![]() |