View previous topic :: :: View next topic

Author 
Message 
alamelu1984
New User
Joined: 20 Apr 2007 Posts: 40 Location: bangalore




What I need to do is to multiply 2 numbers where both the numbers need to be hard coded in my program.
regards
Alamelu 

Back to top 




enricosorichetti
Global Moderator
Joined: 14 Mar 2007 Posts: 10375 Location: italy


Back to top 


alamelu1984
New User
Joined: 20 Apr 2007 Posts: 40 Location: bangalore




thanx enrico sorichetti for that reply..
i was able to solve my prob..
now i have another prob..where i need to multiply a "decimal" number..eg.0.25 with another decimal num...
use of the instruction MP doesnt help as the decimal point doesnt get recognised...plz help me here...
thanx in advance
regards
Alamelu 

Back to top 


enricosorichetti
Global Moderator
Joined: 14 Mar 2007 Posts: 10375 Location: italy




as in any programming language there is no implicit representation for the decimal point...
You must carry on Your own computations..
according to logic and legal constraints, there are rules to be followed..
Yes there are legal constraints also...
for IR ( internal revenue ) the numbers must be represented with 2 decimal digits,
but the computations must be carried on with 4 decimal digits,
beware when carrying on such operations in assembler
the logic for Your need would be ..
transform every number to a integer number with the required number of decimal digits
A = 12 ==> 1200
B = 34 ==> 3400
a * B = 1200 * 3400 = 4080000
c = 408
a = 13 ==> 1300
b = 2 ==> 200
a/B = 65000 ==> 6.50 

Back to top 


alamelu1984
New User
Joined: 20 Apr 2007 Posts: 40 Location: bangalore




thanx for ur inputs enrico sorichetti...
let me paste my code here for you for easier understanding..
BONE EQU *
MVC CAMTCAL,CAMTI
PACK PAMTCAL,PAMTI
MP PAMTCAL,=P'0.4'
UNPK RS,PAMTCAL
OI RS+09,X'F0'
CLC RS,CAMTCAL
BC 4,BONE1
B DUMMY
like i have highlighted above..after the multiplication, i need to check if one of my variable camtcal ( ie. claim amt) is greater than what i have calculated using the MP instruction...
so here my prob is that.. "0.4" isnt really getting recognised..the decimal point is being ignored and the multiplication is happening only with the number '4' and not with '0.4'...plz do help me here..is there another instruction for such a multiplication..??
thanx in advance
regards
Alamelu 

Back to top 


enricosorichetti
Global Moderator
Joined: 14 Mar 2007 Posts: 10375 Location: italy




maybe I was not clear in my previous post...
machine instructions do not recognize decimal numbers.
You must take care of it Yourself
adding the proper number of zeroes to simulate a number with decimal digits
carry on the computations,
rescale the result
example
A = 12 ==>1200 ( 12.00)
B = 34 ==> 3400 ( 34.00 )
C = A * B
step1 1200 * 3400 = 4080000 ( 408.0000)
step2 ( rescale to 2 decimal digits ) 40800 ( 408.00)
assign to c
the edit instruction with a proper mask will display the decimal point 

Back to top 


Phrzby Phil
Active Member
Joined: 31 Oct 2006 Posts: 967 Location: Richmond, Virginia




If both numbers are hardcoded, why not also hardcode the product (i.e., result of mult)? 

Back to top 


enricosorichetti
Global Moderator
Joined: 14 Mar 2007 Posts: 10375 Location: italy




Phrzby Phil wrote: 
If both numbers are hardcoded, why not also hardcode the product (i.e., result of mult)? 
OK... OK... did i win the "dumbest of the day" award
Or the poster was just checking if we paid enough attention to the questions 

Back to top 


alamelu1984
New User
Joined: 20 Apr 2007 Posts: 40 Location: bangalore




thanx enrico sorichetti for ur inputs
will try it out...
regards
Alamelu 

Back to top 


