Hey there! Sign in to join this conversationNew here? Join for free

What is the term to use which says print decimal places only if not zero Watch

    • Thread Starter
    Offline

    2
    ReputationRep:
    I have a programming problem where I need to print decimal digits if they are non-zero.

    This after adding two numbers. Eg if the sum is 5 + 4 then only print 9.

    If the sum is 5.7 + 4, then print 9.7

    And if the sim is 7.1 + 3.222 then print 10.3222

    Excel actually does this.

    Is there a mathematical term to describe this truncating or process of displaying decimal digits?
    • Study Helper
    Online

    13
    Study Helper
    (Original post by acomber)
    I have a programming problem where I need to print decimal digits if they are non-zero.

    This after adding two numbers. Eg if the sum is 5 + 4 then only print 9.

    If the sum is 5.7 + 4, then print 9.7

    And if the sim is 7.1 + 3.222 then print 10.3222

    Excel actually does this.

    Is there a mathematical term to describe this truncating or process of displaying decimal digits?
    Suppress trailing decimal zeroes?

    Best guess. It will be a computing term, rather than mathematical, per se, but I'm not aware of any standard.
    • Thread Starter
    Offline

    2
    ReputationRep:
    I wondered if there was a term. In printf in C the %g format specifier does this.
    • Study Helper
    Online

    13
    Study Helper
    (Original post by acomber)
    I wondered if there was a term. In printf in C the %g format specifier does this.
    "trailing zero(e)s" seems to be the general term. Some languages don't seem to have anything, and require code to perform this task - from a quick Google.

    One should note that 1.00 implies a greater degree of accuracy than just 1.
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    What's your favourite Christmas sweets?
    Useful resources

    Make your revision easier

    Maths

    Maths Forum posting guidelines

    Not sure where to post? Read the updated guidelines here

    Equations

    How to use LaTex

    Writing equations the easy way

    Student revising

    Study habits of A* students

    Top tips from students who have already aced their exams

    Study Planner

    Create your own Study Planner

    Never miss a deadline again

    Polling station sign

    Thinking about a maths degree?

    Chat with other maths applicants

    Can you help? Study help unanswered threads

    Groups associated with this forum:

    View associated groups
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.