Author: Mathieu Pagé
Date: 05:40:42 09/18/03
Go up one level in this thread
On September 18, 2003 at 08:12:26, Joel wrote:
>Hey All,
>
>I am well aware that this probably has been answered before, but I cannot find
>anything! :|
>
>How do I display the value of a unsigned __int64 in Visual C++ when using
>printf?
>
>
>Regards,
>Joel
Hi Joel,
This is how i do (it display the value un binary on 8 rank :)
<code>
///////////////////////////////////////////////////////////////////////////////
// Sommaire: Retourne une chaine representant un bitsboard
//
// Description: Retourne une chaine représentant un BitBoard au format
// décimale et binaire, de facon formaté comme suit:
//*****************************************************************************
// BitBoard: 987432168
// Visualisation:
// ------------
// | 10010001 |
// | 01001010 |
// | 10011010 |
// | 10010011 |
// | 11010111 |
// | 11101110 |
// | 10101011 |
// | 00000100 |
// ------------
//*****************************************************************************
//
// Entrée: BitBoard bit : Le bitsBoard à afficher.
//
// Sortie: Une string contennant l'affichage formaté du BitBoard
//
// Notes: Affin d'améliorer les performances sur les processeurs 32
// bits le BitBoard est séparé en deux parties afin d'être
// imprimmé comme deux bitsBoard de 32 bits
///////////////////////////////////////////////////////////////////////////////
std::string AfficherBitsBoard(BitBoard bit)
{
ostringstream out;
const BitBoard Masque32 = B(0xFFFFFFFF); // BitBoard masque des 32
// premiers bits.
const int i32Positions[32] =
{
0x00000001, 0x00000002,
0x00000004, 0x00000008,
0x00000010, 0x00000020,
0x00000040, 0x00000080,
0x00000100, 0x00000200,
0x00000400, 0x00000800,
0x00001000, 0x00002000,
0x00004000, 0x00008000,
0x00010000, 0x00020000,
0x00040000, 0x00080000,
0x00100000, 0x00200000,
0x00400000, 0x00800000,
0x01000000, 0x02000000,
0x04000000, 0x08000000,
0x10000000, 0x20000000,
0x40000000, 0x80000000
};
int iBas;
int iHaut;
int i;
iBas = int(bit & Masque32);
iHaut = int((bit >> 32) & Masque32);
out <<endl
<<" BitBoard: " <<bit <<endl
<<" Visualisation:" <<endl
<<" ------------" <<endl;
for (i = 0; i < 32; i+=8)
{
out <<" | ";
for (int j = 0; j < 8; j++)
{
out <<(((iBas & i32Positions[i+j]) == 0)?'0':'1');
}
out <<" |" <<endl;
}
for (i = 0; i < 32; i+=8)
{
out <<" | ";
for (int j = 0; j < 8; j++)
{
out <<(((iHaut & i32Positions[i+j]) == 0)?'0':'1');
}
out <<" |" <<endl;
}
out <<" ------------" <<endl;
return out.str();
}
</code>
<output>
BitBoard: 987432168
Visualisation:
------------
| 10010001 |
| 01001010 |
| 10011010 |
| 10010011 |
| 11010111 |
| 11101110 |
| 10101011 |
| 00000100 |
------------
</output>
The code is in french, but i'm sure you can understand it. If you need more
explanation, dont be afraid to let me know.
Hope it help
Mathieu Pagé
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.