Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Divison by a decimal point numbers

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
renzreny

New User


Joined: 16 Oct 2008
Posts: 7
Location: USA

PostPosted: Tue Nov 25, 2008 8:11 pm    Post subject: Divison by a decimal point numbers
Reply with quote

Hello,

I've come across a scenario where I'd need to divide a number by 365.25 in assembler. Let's say we've a variable VARA that will have values ranges from 0 - 36525. I'd need to divide VARA by 365.25. Quotient part of the result is needed to do further processing of my logic.

Note that dividend will always be a numeric number and only divisor has the fractional part

Please help me lead to the solution for the same. Please advise me incase additional informations needed.

Thanks,
reny
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Tue Nov 25, 2008 8:17 pm    Post subject:
Reply with quote

Review the floating point instructions in HLASM.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Tue Nov 25, 2008 8:50 pm    Post subject: Reply to: Divison by a decimal point numbers
Reply with quote

if You are trying to carry on date conversions check the CBT tape for working programs

anyway no need to use floating points for date calculations,

for packed decimal You have to carry on Your own virtual decimal point handling
Back to top
View user's profile Send private message
renzreny

New User


Joined: 16 Oct 2008
Posts: 7
Location: USA

PostPosted: Tue Nov 25, 2008 9:13 pm    Post subject:
Reply with quote

Yes...I was actually using it for "age calculation logic". Here the scenario is to calculate the age when birthdate is given.

What I've thought to achieve is (logic in highlevel) ....

TODAYDATE = (Current Year * 365) + (Current Month in days) + (Current Day)
BIRTHDATE = (B'day year * 365)+ (B'day month in days)+ (day)

AGE is calculated as (TODAYDATE - BIRTHDATE) / 365

The results are nearly okay. But it will not be perfect always as leapyear is not taking care. In googling, I got to understand that if 365.25 days are used (instead of 365) in above calculation, result will be almost accurate. Please advise me whether there is any better way to accomplish this to calculate age when b'day is given. It would be grateful if anyone has sample handy. Thanks in advance.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Tue Nov 25, 2008 10:43 pm    Post subject: Reply to: Divison by a decimal point numbers
Reply with quote

again check the cbttape for ready to run code
http://www.cbttape.org
Back to top
View user's profile Send private message
renzreny

New User


Joined: 16 Oct 2008
Posts: 7
Location: USA

PostPosted: Wed Nov 26, 2008 6:54 pm    Post subject:
Reply with quote

Thanks you so much enrico-sorichetti!!. icon_biggrin.gif

You directed me to the right place where I've got it resolved....

It was just a matter of plug-in and play (with minor enhancements) icon_cool.gif


Thanks,
renz
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Incorrect output when trying to add n... monica1 PL/I & Assembler 10 Fri Jan 13, 2017 5:02 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Online Assembler Program Starting point Aditya.Srivastava PL/I & Assembler 4 Fri Jul 08, 2016 6:48 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us