Any limitation on size when using Iconv and Oconv with "
Moderators: chulett, rschirm, roy
I had problems with MOD() on numbers over a certain size and I didn't see a need to bump up the EXACTNUMERIC value so I wrote an "SMOD" routine that used the string math functions I mentioned earlier to do a proper mod on any big ass number. Worked fine for me.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
manuel.gomez
- Premium Member

- Posts: 291
- Joined: Wed Sep 26, 2007 11:23 am
- Location: Madrid, Spain
No idea on those string math functions.chulett wrote:I had problems with MOD() on numbers over a certain size and I didn't see a need to bump up the EXACTNUMERIC value so I wrote an "SMOD" routine that used the string math functions I mentioned earlier to do a proper mod on any big ass number. Worked fine for me.
Are these basic ones? or C routines you wrote for parallel jobs?
If they are pre-written within datastage, can you please recommend any of those so can match my needs for base10-base2 conversions?
Thanks!!!
-
manuel.gomez
- Premium Member

- Posts: 291
- Joined: Wed Sep 26, 2007 11:23 am
- Location: Madrid, Spain
-
manuel.gomez
- Premium Member

- Posts: 291
- Joined: Wed Sep 26, 2007 11:23 am
- Location: Madrid, Spain
Hi guys!!!
I got a solutions thanks to chulett indications with string maths functions
The SMOD function I wrote is the following
I know that the field function is not the more elegant choice, but I wanted the int number, and I could not solve it just with the sdiv function
Now, the "only" problem left is negative numbers to be converted longer than 15 length
When number is negative, to turn it from base10 to base2, you have to convert absolute value into base2, and add 1
But I am not sure to be able to do this add 1 operation once I got the binary value from the first step.
Any suggestions guys?
I got a solutions thanks to chulett indications with string maths functions
The SMOD function I wrote is the following
Code: Select all
cocte = field(sdiv(Arg1,Arg2), '.', 1)
Ans = ssub(Arg1,smul(cocte, Arg2))Now, the "only" problem left is negative numbers to be converted longer than 15 length
When number is negative, to turn it from base10 to base2, you have to convert absolute value into base2, and add 1
But I am not sure to be able to do this add 1 operation once I got the binary value from the first step.
Any suggestions guys?
-
ray.wurlod
- Participant
- Posts: 54595
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Would you describe these, therefore, as steatopygous functions?chulett wrote:I had problems with MOD() on numbers over a certain size and I didn't see a need to bump up the EXACTNUMERIC value so I wrote an "SMOD" routine that used the string math functions I mentioned earlier to do a proper mod on any big ass number. Worked fine for me.
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.
-
ray.wurlod
- Participant
- Posts: 54595
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Why, it seems that one could.ray.wurlod wrote:Would you describe these, therefore, as steatopygous functions?chulett wrote:I had problems with MOD() on numbers over a certain size and I didn't see a need to bump up the EXACTNUMERIC value so I wrote an "SMOD" routine that used the string math functions I mentioned earlier to do a proper mod on any big ass number. Worked fine for me.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
manuel.gomez
- Premium Member

- Posts: 291
- Joined: Wed Sep 26, 2007 11:23 am
- Location: Madrid, Spain
We can say so, yesray.wurlod wrote:It's not really "add one" though, is it? It's more "set the sign bit". This can readily be done with string manipulation.
These are the steps I would follow:
- Remove the minus sign from the input value
- Use my function to turn argument into base10
- Change 0's into 1's and 1's into 0's
- Set the sign bit, adding 1 to the previous result (complent two)
For example, lets say we are receiving input value: -12
Step1: 12
Step2: 1100
Step3: 0011
Step4: 0100
But with the code I do have now, I dont know how to do step4
Any ideas please?
Thanks very much!
-
ray.wurlod
- Participant
- Posts: 54595
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The one that jumps to mind is to do it in decimal - subtract the next higher power of 2 from the absolute value of the original number then convert to binary. It would probably be easy to create an AddBit function.
Code: Select all
FUNCTION AddBit(BinaryString)
Begin Case
Case UnAssigned(BinaryString) Or IsNull(BinaryString)
Ans = @NULL
Case Len(Convert("01","",BinaryString)) > 0
Ans = @NULL ; * argument is not a binary string
Case @TRUE
Ans = BinaryString
RPos = Len(BinaryString)
Carry = @FALSE
For BitPos = RPos To 1 Step -1
If Ans[BitPos,1] = 0
Then
Ans[BitPos,1] = "1"
Exit ; * exit from loop
End
Else
Ans[BitPos,1] = "0"
If BitPos = 1 Then Carry = @TRUE
End
Next BitPos
If Carry
Then
Ans = "1" : Ans
End
End Case
RETURN(Ans)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.
-
manuel.gomez
- Premium Member

- Posts: 291
- Joined: Wed Sep 26, 2007 11:23 am
- Location: Madrid, Spain
Thanks very much Ray!!
I am almost done!!!
Now I have a doubt on how Oconv function converted a numeric number
I did the following:
And returned result for input value: -12 was
I am almost done!!!
Now I have a doubt on how Oconv function converted a numeric number
I did the following:
Code: Select all
CASE len(Arg1)<=15
* For numbers shorter than 15, we use Oconv function, that will be faster
Ans=Oconv(Arg1, "MB")
Why all this heading 1's? I was expecting 0100 to be returned!11111111111111111111111111110100
-
ray.wurlod
- Participant
- Posts: 54595
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That's the correct result in a twos-complement setting. A 32-bit signed negative integer is represented as 65536 + (value). In this case, 65536 + (-12) = 65534. Binary representation of 65534 is 11111111111111111111111111110100.
Positive signed integers range from 0 through 32767.
Positive signed integers range from 0 through 32767.
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.
-
manuel.gomez
- Premium Member

- Posts: 291
- Joined: Wed Sep 26, 2007 11:23 am
- Location: Madrid, Spain
Great, I think we can consider this as solvedray.wurlod wrote:That's the correct result in a twos-complement setting. A 32-bit signed negative integer is represented as 65536 + (value). In this case, 65536 + (-12) = 65534. Binary representation of 65534 is 11111111111111111111111111110100.
Positive signed integers range from 0 through 32767.
Thanks very much for you help guys!!!
