View previous topic :: View next topic
|
Author |
Message |
renzreny
New User
Joined: 16 Oct 2008 Posts: 7 Location: USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Review the floating point instructions in HLASM. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
renzreny
New User
Joined: 16 Oct 2008 Posts: 7 Location: USA
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
renzreny
New User
Joined: 16 Oct 2008 Posts: 7 Location: USA
|
|
|
|
Thanks you so much enrico-sorichetti!!.
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)
Thanks,
renz |
|
Back to top |
|
|
|