Thread: Super type to the rescue!

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912

    Super type to the rescue!

    I have a program, done with templates, so that I can handle every type. I need it to at least be numerical, so I need to convert chars to numbers. Doing that however, I need to find a type that I can convert to, that doesn't lose any info. For example, if I do (int)a_float I lose the decimal portion. Is there a type I can convert to, that will allow me to lose nothing? It's okay if there isn't - it just means my program (actually its a library) won't work as well as it could, and I would have to do a lot more coding.

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    You could convert to the largest possible type. It doesn't sound like you're using templates properly, though.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I'm not. They just make my job a lot easier the way I am. Thanks. I think doubles should work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 12:59 AM
  3. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  4. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM