Page 1 of 1

Placing a constraint in transformer

Posted: Thu Jan 10, 2008 5:27 pm
by RAJEEV KATTA
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.

Posted: Thu Jan 10, 2008 6:58 pm
by ray.wurlod
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.

Posted: Fri Jan 11, 2008 1:18 pm
by RAJEEV KATTA
The example of 5678.01 the mantissa should be 01 the values after decimal.

Posted: Fri Jan 11, 2008 1:29 pm
by ds
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:

Code: Select all


      If ( IsNull(InputNumber) Or (Len(Trim(InputNumber)) = 0) ) Then
         Ans = 0
      End Else
         Ans = InputNumber
      End


Posted: Fri Jan 11, 2008 1:38 pm
by RAJEEV KATTA
If the value is 5678.00 or 5678. then the value turns out to be 0.But I want to send the output only when it is not a whole number like "5678.00' and not "5678.".

Posted: Fri Jan 11, 2008 1:59 pm
by ds
Do we have the following as two different cases:

1) 5678.00
2) 5678.

:?: :?: :?:

I mean if it is a decimal datatype defined on the field, do you really have data with a decimal point and without a mantissa (as in the second case above) ?

Posted: Fri Jan 11, 2008 3:35 pm
by RAJEEV KATTA
The input field datatype is varchar but as to your question the second one can have data without mantissa I mean 5678. What I am actually looking is if the input is not a whole no I need to pass it to output.

Posted: Fri Jan 11, 2008 3:49 pm
by ray.wurlod
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.

Posted: Fri Jan 11, 2008 4:02 pm
by ds
Indeed :?

Why would you need to have a decimal point if there is no mantissa and just a characteristic defined to it ?

I mean this is a whole number in itself :?:

- James

Posted: Fri Jan 11, 2008 5:12 pm
by chulett
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: