playMaker

Author Topic: Help with string/float formatting  (Read 924 times)

Aaddiction

  • Full Member
  • ***
  • Posts: 166
Help with string/float formatting
« on: May 11, 2020, 12:27:00 PM »
Hello,

I'm making a time manager that measures the difference between two time intervals. Best race lap time vs current lap time. So the time float is sometimes positive and sometimes negative.

When it's negative and I format the float with "{2:D2}:{3:D2}:{4:D3}" it shows 00m:-3s:-5ms. I want the minus (-) to be only in front when converting to string. Example: - 00:03:05, and not 00:-03:-05.

How to do that, I guess format or build string?
« Last Edit: May 12, 2020, 07:38:23 AM by Aaddiction »

drown

  • Junior Playmaker
  • **
  • Posts: 58
Re: Help with string/float formatting
« Reply #1 on: June 10, 2020, 06:53:38 AM »
Hey there, I know its a late reply but maybe it is still relevant.

You can do this multiple ways but the simplest way would be to remove all "-" from the string entirely using "String Replace" and simply replace "-" with "" (nothing).

You could then use "Build String" and build your final output from 2 elements :a minus "-" and the result from the "String Replace".