Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
field width in floating point with negative and positive numbers

Subject: field width in floating point with negative and positive numbers

From: Misha Koshelev

Date: 14 May, 2009 15:40:17

Message: 1 of 1

Hi very simple question, I'd like to print out a string with a given field with that stays consistent with positive or negative floating-point numbers. Matlab claims that something like %5.2f does this, but I get a number that is one character longer in the negative variant. I know I can do %+5.2f but it looks ugly, is there an alternative where the + doesn't get printed but we still get the same total # of characters when printing a positive or negative number?

Thank you
Misha

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us