Super type to the rescue!

This is a discussion on Super type to the rescue! within the C++ Programming forums, part of the General Programming Boards category; I have a program, done with templates, so that I can handle every type. I need it to at least ...

  1. #1
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913

    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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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, 09:18 PM
  2. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 01:59 AM
  3. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 02:09 PM
  4. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 01:22 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21