Replacing a Decimal with a letter in a numeric variable.

This is a discussion on Replacing a Decimal with a letter in a numeric variable. within the C++ Programming forums, part of the General Programming Boards category; I need to replace a Numeric variable containing a decimal such as 130.25 to have the decimal changed to a ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    1

    Replacing a Decimal with a letter in a numeric variable.

    I need to replace a Numeric variable containing a decimal such as 130.25 to have the decimal changed to a P such as 130P25. The software I am writing this program for does not recognize a decimal in the naming convention. Does anyone have a clue how this might work. The main problem is the the numbers before and after the decimal can vary in length. So the TAKE command wasn't working. IS there a way to make the program hold 000.00 as the place holder so that a number lik 5.3 would turn into 005.30?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    Create a string out of it, then use the replace() method to replace the dot with a P
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replacing an Event with a boolean variable.
    By Hunter2 in forum Windows Programming
    Replies: 2
    Last Post: 08-13-2008, 01:49 PM
  2. Big Letter became small letter
    By cogeek in forum C Programming
    Replies: 27
    Last Post: 12-13-2004, 01:04 PM
  3. Problem with a char variable set as a letter
    By 7smurfs in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2004, 12:25 PM
  4. Beginner question
    By Tride in forum C Programming
    Replies: 30
    Last Post: 05-24-2003, 08:36 AM
  5. Replies: 13
    Last Post: 08-15-2002, 09:20 AM

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