Placing a constraint in transformer
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 103
- Joined: Wed Jul 06, 2005 12:29 am
Placing a constraint in transformer
I have a scenario where in I have to pass the records to output if the input field value is not a whole no for ex-:5678.00 or 5678.01.I extracted the mantissa from decimal and said if num(extracted value)=1 then pass the record but there are input records like 5678. & the mantissa value is getting extracted as 0 instead of blank which is creating problem.What function is best to resolve this issue.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Give examples. The mantissa of 5768.01 should be 576801 or 5.76801, depending on the convention you are using, never 1 or 0.
Reading between the lines, it appears that you need to compare the original number with itself having had a Floor() function applied.
Reading between the lines, it appears that you need to compare the original number with itself having had a Floor() function applied.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 103
- Joined: Wed Jul 06, 2005 12:29 am
When you say 'num(extracted value)=1', do you mean the condition as
num(extracted value)=TRUE
Also, the extracted value you get is NULL, is this the case when mantissa is 0 only or always ? In case it is NULL, only when the mantissa is supposed to be 0, you can create a basic routine to convert a NULL to zero and use it there...something as the one below:
num(extracted value)=TRUE
![Question :?:](./images/smilies/icon_question.gif)
Also, the extracted value you get is NULL, is this the case when mantissa is 0 only or always ? In case it is NULL, only when the mantissa is supposed to be 0, you can create a basic routine to convert a NULL to zero and use it there...something as the one below:
Code: Select all
If ( IsNull(InputNumber) Or (Len(Trim(InputNumber)) = 0) ) Then
Ans = 0
End Else
Ans = InputNumber
End
-
- Participant
- Posts: 103
- Joined: Wed Jul 06, 2005 12:29 am
-
- Participant
- Posts: 103
- Joined: Wed Jul 06, 2005 12:29 am
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That is the strangest definition of mantissa that I have ever encountered, and I believe it to be wrong.
If the field is a string, use Field(InLink.TheField, ".", 2, 1) to identify that component following the decimal placeholder ("." assumed) and compare that against zero.
If the field is a decimal, use Floor() to compute that part to the left of the decimal placeholder, subtract that from the original value, and compare the result to zero.
If the field is a float or a dfloat then you have an issue because, under the IEEE conventions for storing floating point numbers, exact representation can not be guaranteed - you could try converting to decimal and proceeding as above, but no promises.
In my understanding, mantissa and exponent are most easily explained when the number is represented using scientfic notation. The mantissa is that part to the left of the "E", the exponent is that part to the right. For example 5678.01 is 5.67801E03; the mantissa is 5.67801 and the exponent is 3. Or, if 5678.01 is represented as 567801E-02 then the mantissa is 567801 and the exponent is -2.
If the field is a string, use Field(InLink.TheField, ".", 2, 1) to identify that component following the decimal placeholder ("." assumed) and compare that against zero.
If the field is a decimal, use Floor() to compute that part to the left of the decimal placeholder, subtract that from the original value, and compare the result to zero.
If the field is a float or a dfloat then you have an issue because, under the IEEE conventions for storing floating point numbers, exact representation can not be guaranteed - you could try converting to decimal and proceeding as above, but no promises.
In my understanding, mantissa and exponent are most easily explained when the number is represented using scientfic notation. The mantissa is that part to the left of the "E", the exponent is that part to the right. For example 5678.01 is 5.67801E03; the mantissa is 5.67801 and the exponent is 3. Or, if 5678.01 is represented as 567801E-02 then the mantissa is 567801 and the exponent is -2.
Last edited by ray.wurlod on Fri Jan 11, 2008 6:26 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Looked up the term as I hadn't heard it used like this.
http://en.wikipedia.org/wiki/Mantissa
Also found this:
http://en.wikipedia.org/wiki/Significan ... antissa.22
Doesn't really help, just thought it was interesting enough to share.![Wink :wink:](./images/smilies/icon_wink.gif)
http://en.wikipedia.org/wiki/Mantissa
Also found this:
http://en.wikipedia.org/wiki/Significan ... antissa.22
Doesn't really help, just thought it was interesting enough to share.
![Wink :wink:](./images/smilies/icon_wink.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers