'Datastage constraint to filter decimal values
In Datastage, I had a requirement, from a list of values (varchar datatype) (for example 10.25, 8.10, 8.40, etc) I need to evaluate if the number is > 0 but not divisible by 0.5 and need to be sent in tinyint any suggestion? Thanks.
Solution 1:[1]
If your values are coming in a comma-separated string then you'll need to find a way to get them out first, field might be the way forward here.
Once you get the numbers, the standard test for divisible by 0.5 is: Div(<value>, 0.5) * 0.5 = <value>, i.e. divide the number by 0.5, take only the whole number part, then multiply it back up by 0.5 to see if you get the same number again.
Here's some examples, in case that isn't clear:
- 1.5 -> 1.5 / 0.5 = 3.0, then 3 * 0.5 = 1.5 - this is the original number so it IS divisible by 0.5
- 2.1 -> 2.1 / 0.5 = 4.2, then 4 * 0.5 = 2.0 - this isn't the original number so this one IS NOT divisible by 0.5
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Richard Hansell |
