Program: gdcm
Module: $RCSfile: gdcmUtil.cxx,v $
Language: C++
- Date: $Date: 2005/01/21 20:49:37 $
- Version: $Revision: 1.117 $
+ Date: $Date: 2005/01/22 01:40:41 $
+ Version: $Revision: 1.118 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// 3 OS: Win32, SunOS and 'real' POSIX
// http://groups-beta.google.com/group/comp.unix.solaris/msg/ad36929d783d63be
// http://bdn.borland.com/article/0,1410,26040,00.html
- union dual { uint64_t n; unsigned char addr[6]; };
+ unsigned char addr[6];
+ uint64_t n = 0;
- // zero-initialize the whole thing first:
- dual d = { 0 };
- int stat = GetMacAddrSys(d.addr);
+ int stat = GetMacAddrSys(addr);
if (stat == 0)
{
- // fill with zero to fit on 15 bytes.
+ // Horner evaluation
+ for(int i=0; i<6; i++)
+ {
+ n *= 256;
+ n += addr[i];
+ }
+
+ // we fit on 15 bytes maximum < 256^6.
#if defined(_MSC_VER) || defined(__BORLANDC__)
- return Format("%015I64u", d.n);
+ return Format("%I64u", n);
#else
- return Format("%015llu", d.n);
+ return Format("%llu", n);
#endif
}
else