Thread: decimal points

  1. #1
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125

    Smile decimal points

    how could you output a number into a edit box that has as many decimal points as the number and cuts off the remainder at four places past the decimal point. EX
    1 wouldn't be 1.00000
    1.345432 would be 1.3454
    Thanx in Advance
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    If I understand correctly, write a filter for numbers with zeros then print into string.

    ie
    if(((fNumber*100)%10==0)&&((fNumber*1000)%100==0)& &.......)
    sprintf(sBuffer,"04.0f",fNumber);
    else
    sprintf(sBuffer,"%04.4f",fNumber);
    SetDlgItemText(GetDlgItem(hDlg,IDC_EDIT),sBuffer);
    (you get the idea)
    Last edited by novacain; 04-29-2002 at 10:18 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help it won't compile!!!!!
    By esbo in forum C Programming
    Replies: 58
    Last Post: 01-04-2009, 03:22 PM
  2. Replies: 8
    Last Post: 11-03-2008, 09:48 PM
  3. Yahtzee C++ programme help
    By kenneth_888 in forum C++ Programming
    Replies: 13
    Last Post: 09-05-2007, 02:14 PM
  4. CProg Fantasy Football version pi
    By Govtcheez in forum A Brief History of Cprogramming.com
    Replies: 155
    Last Post: 12-26-2006, 04:30 PM
  5. Decimal Points and Binary Points
    By Shadow12345 in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 11-07-2002, 01:06 AM