Click here to Skip to main content
15,887,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Netbeans C++ Sqlite3 Pin
Richard MacCutchan16-Feb-10 8:10
mveRichard MacCutchan16-Feb-10 8:10 
AnswerRe: Netbeans C++ Sqlite3 Pin
CPallini16-Feb-10 11:15
mveCPallini16-Feb-10 11:15 
GeneralRe: Netbeans C++ Sqlite3 Pin
xivShin16-Feb-10 18:44
xivShin16-Feb-10 18:44 
GeneralRe: Netbeans C++ Sqlite3 Pin
CPallini16-Feb-10 20:53
mveCPallini16-Feb-10 20:53 
QuestionStatic Const Initialization Pin
Skippums16-Feb-10 3:17
Skippums16-Feb-10 3:17 
AnswerRe: Static Const Initialization Pin
«_Superman_»16-Feb-10 3:32
professional«_Superman_»16-Feb-10 3:32 
GeneralRe: Static Const Initialization Pin
Skippums16-Feb-10 3:36
Skippums16-Feb-10 3:36 
AnswerRe: Static Const Initialization Pin
Skippums16-Feb-10 4:37
Skippums16-Feb-10 4:37 
OK... I found a pretty good thread here[^] that talks about initialization of static const template members. I still don't understand why the code I originally posted doesn't work, but I did see a statement in this post that clearly indicated that all compile-time constant initialized static const members are performed prior to all dynamically initialized static members. Therefore, I decided to remove the dependencies on all dynamically defined static const members, instead repeating the math based on MantissaSize which is ALWAYS (according to the referenced post) defined prior to the other members. Now when I run, I no longer get any errors, and instead get the intended result. I copied my new code below:
// Template structures used to get information about IEEE floating-point formats
template<size_t bytes> struct __float {
public:
    // Mantissa size, in bits
    static const __uint8  MantissaSize;
    // Significand size, in bits
    static const __uint8  SignificandSize;
    // Exponent size, in bits
    static const __uint8  ExponentSize;
    // The maximum representable exponent (reserved for inf and NaN)
    static const __uint16 ExponentMax;
    // The exponent bias
    static const __uint16 ExponentBias;
    // An integer with only the bit left of the mantissa set
    static const __int64 SignificandBit;
    // An integer with all bits included in the mantissa set
    static const __int64 MantissaMask;
    // An integer with all bits included in the mantissa set,
    //   as well as the bit left of the mantissa
    static const __int64 SignificandMask;
    // An integer with all bits included in the exponent set
    static const __int64 ExponentMask;
};
    
// Defines the constants used by the __float structure
template<> const __uint8 __float<2>::MantissaSize = 10;
template<> const __uint8 __float<4>::MantissaSize = 23;
template<> const __uint8 __float<8>::MantissaSize = 52;
    
// Compute the constants for the __float structure
template<size_t bytes>
const __uint8  __float<bytes>::SignificandSize = __float<bytes>::MantissaSize + 1;
template<size_t bytes>
const __uint8  __float<bytes>::ExponentSize    =
    (bytes << 3) - __float<bytes>::MantissaSize - 1;
template<size_t bytes>
const __uint16 __float<bytes>::ExponentMax     =
    (1 << ((bytes << 3) - __float<bytes>::MantissaSize - 1)) - 1;
template<size_t bytes>
const __uint16 __float<bytes>::ExponentBias    =
    (1 << ((bytes << 3) - __float<bytes>::MantissaSize - 2)) - 1;
template<size_t bytes>
const __int64 __float<bytes>::SignificandBit   =
    1LL << __float<bytes>::MantissaSize;
template<size_t bytes>
const __int64 __float<bytes>::MantissaMask     =
    (1LL << __float<bytes>::MantissaSize) - 1;
template<size_t bytes>
const __int64 __float<bytes>::SignificandMask  =
    (1LL << (__float<bytes>::MantissaSize + 1)) - 1;
template<size_t bytes>
const __int64 __float<bytes>::ExponentMask     =
    ((1LL << ((bytes << 3) - __float<bytes>::MantissaSize - 1)) - 1)
    << __float<bytes>::MantissaSize;
Again, if anyone can explain why my initial code didn't work I would really appreciate it. Thanks,
Sounds like somebody's got a case of the Mondays

-Jeff

QuestionMFC Dragging Image Pin
RS.Ratheesh16-Feb-10 0:04
RS.Ratheesh16-Feb-10 0:04 
QuestionCom With multiple reference conflict Pin
Ash_VCPP15-Feb-10 23:32
Ash_VCPP15-Feb-10 23:32 
QuestionRe: Com With multiple reference conflict Pin
CPallini16-Feb-10 0:07
mveCPallini16-Feb-10 0:07 
AnswerRe: Com With multiple reference conflict Pin
Ash_VCPP16-Feb-10 1:05
Ash_VCPP16-Feb-10 1:05 
QuestionRe: Com With multiple reference conflict Pin
CPallini16-Feb-10 1:19
mveCPallini16-Feb-10 1:19 
AnswerRe: Com With multiple reference conflict Pin
Ash_VCPP16-Feb-10 1:37
Ash_VCPP16-Feb-10 1:37 
GeneralRe: Com With multiple reference conflict Pin
CPallini16-Feb-10 20:55
mveCPallini16-Feb-10 20:55 
QuestionChanging exe icon at runtime Pin
learningvisualc15-Feb-10 23:01
learningvisualc15-Feb-10 23:01 
AnswerRe: Changing exe icon at runtime Pin
Code-o-mat15-Feb-10 23:22
Code-o-mat15-Feb-10 23:22 
AnswerRe: Changing exe icon at runtime Pin
Saurabh.Garg16-Feb-10 1:01
Saurabh.Garg16-Feb-10 1:01 
QuestionInsert data of more than 4000 characters in clob datatype Pin
MsmVc15-Feb-10 21:06
MsmVc15-Feb-10 21:06 
QuestionRe: Insert data of more than 4000 characters in clob datatype Pin
David Crow16-Feb-10 3:57
David Crow16-Feb-10 3:57 
AnswerRe: Insert data of more than 4000 characters in clob datatype Pin
MsmVc16-Feb-10 19:26
MsmVc16-Feb-10 19:26 
GeneralRe: Insert data of more than 4000 characters in clob datatype Pin
David Crow17-Feb-10 3:06
David Crow17-Feb-10 3:06 
QuestionApplication Theme changes automatically Pin
Harsh Shankar15-Feb-10 20:27
Harsh Shankar15-Feb-10 20:27 
AnswerRe: Application Theme changes automatically Pin
Eugen Podsypalnikov16-Feb-10 6:41
Eugen Podsypalnikov16-Feb-10 6:41 
GeneralRe: Application Theme changes automatically Pin
Harsh Shankar17-Feb-10 6:31
Harsh Shankar17-Feb-10 6:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.