Using floats / decimals as integers in a workflow and vice versa

It might be a bit unusual as a question but I was wondering if it is possible to allow CWL accept different numerical value types to be exchanged between them.

For example when providing the integer 20 it will be converted to 20.0 when a float is required.

This way you can use one format when using whole numbers. I was wondering about this as I have a set of workflows in which floats are used for some workflows and integers are used in others and it would be great if i could use the same value either 20.0 or 20 in both ways.

This of course should not work when you pass on 20.5 to an integer as this might give bigger problems when the numbers are rounded up or down.

Hey @jjkoehorst , thanks for posting this idea

I see the advantages to the user, but I feel like auto-rounding is asking for trouble.

Another option would be to allow for auto-conversion, but only where there is no loss of precision.

Third option is to change nothing in the CWL standards, but to remind people that they can choose to allow for multiple (numeric) input types and to handle any rounding in a manner that they see fit.

inputs:
  foo:
    type: [ int, long, float, double ]   # just give me a number!

I agree to not round numbers as precision will be lost except when the precision does not change e.g. 20.0 > 20 as parameters of applications might like 20 but do not understand 20.0

What about

step:
  my_float:
    source: an_int
    valueFrom: |
      ${
            return parseFloat(self.toString());
      }

Again, I agree that one should proceed with caution, but if the main purpose is to overcome parsing errors, then this should be fine

1 Like