In decimal, the 0 at the end is removed

Is there a way around this, because the 0 is often still used, e.g. with money, 1.70 then becomes 1.7 It would be possible with a character string, but since I'm still calculating with the variable, this doesn't work
 

Dimlos

Well-known member
This may not be a good solution, but shell scripts can compute string variables.
 

Attachments

  • macro.jpg
    macro.jpg
    380.7 KB · Views: 23
  • decimal_calculation.macro
    2.1 KB · Views: 5

Dm114

Well-known member
Is there a way around this, because the 0 is often still used, e.g. with money, 1.70 then becomes 1.7 It would be possible with a character string, but since I'm still calculating with the variable, this doesn't work
I use a Block Action I've written a long time ago. If you are interested you can use it.

1⁰) To format decimal numbers with any chosen thousands separator (none by default) and rounding to desired number of decimals.
2⁰) To display large decimal numbers (from 1.0E7) without scientific notation (with or without thousands separator).

• Input variables:
– Decimal: dIN
– Optional thousands separator character: Sep (any character except dot/decimal point)
– Optional number of decimals: Dps (assuming that any negative value means floating, i.e. no rounding)
• Output variable:
– Formatted string: sOUT

HINT: if you plan to always use the same 1000s separator in your future calls of this Action block, you can enter its value in the Sep variable below and save this Action block to update it. Thus it'll become the default value and you won't have to select this variable as input field anymore. However you'll then be able to set another separator character for a specific call but you won't be able to set this separator to (none) as the default value will be the one you previously entered in this Action block.

 

hugojans

New member
I use a Block Action I've written a long time ago. If you are interested you can use it.

1⁰) To format decimal numbers with any chosen thousands separator (none by default) and rounding to desired number of decimals.
2⁰) To display large decimal numbers (from 1.0E7) without scientific notation (with or without thousands separator).

• Input variables:
– Decimal: dIN
– Optional thousands separator character: Sep (any character except dot/decimal point)
– Optional number of decimals: Dps (assuming that any negative value means floating, i.e. no rounding)
• Output variable:
– Formatted string: sOUT

HINT: if you plan to always use the same 1000s separator in your future calls of this Action block, you can enter its value in the Sep variable below and save this Action block to update it. Thus it'll become the default value and you won't have to select this variable as input field anymore. However you'll then be able to set another separator character for a specific call but you won't be able to set this separator to (none) as the default value will be the one you previously entered in this Action block.

Hi Dm114, the link to your - presumably - very interesting Action Block is broken. Can it be made to work again? Thanks in advance!
 

Dm114

Well-known member
Yes! And I used it already in my macro to format numbers before writing them to a log file. Very useful!...
I don't know why the Action Block's name became "fⁿDispDec# 2" instead of "fⁿDispDec#" in the Template store? Of course you can rename as you like.
 

Endercraft

Moderator (& bug finder :D)
I don't know why the Action Block's name became "fⁿDispDec# 2" instead of "fⁿDispDec#" in the Template store? Of course you can rename as you like.
It's just action blocks bugs. It's annoying sometimes because you get weird name like "action block 2 2 2 2" (this did happen to me).
 

MacroDroidDev

Administrator
Staff member
This happens if the action block already exists on your device (so new downloaders wont see this happen). It detects the action block as being different as it is assigned a new unique id when it gets uploaded to the template store. I will see if there is a way I can detect that it is the same action block and prevent the addition of the 2 suffix.
 
Top