IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Divison by a decimal point numbers


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

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

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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Nov 25, 2008 8:50 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Nov 25, 2008 10:43 pm
Reply with quote

again check the cbttape for ready to run code
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Point and Shoot )PTNS TSO/ISPF 0
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts A directory in the pathname was not f... ABENDS & Debugging 0
Search our Forums:

Back to Top