473,320 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Macro to calculate seconds of a year ( 16 bit processor)

Hi
Can anyone guide me by providing me the code ,for the following
requirement:
how to write a macro for a 16 bit processor that returns the
calculated seconds of a year assuming 365 days in a year ?

Thanking you in advance

Nov 20 '06 #1
8 6979
"Shilpa" <sh***********@gmail.comwrote:
Hi
Can anyone guide me by providing me the code ,for the following
requirement:
how to write a macro for a 16 bit processor that returns the
calculated seconds of a year assuming 365 days in a year ?
#define NUMBER_OF_SECONDS_IN_A_SHORT_YEAR 31536000L

HTH; HAND.

Richard
Nov 20 '06 #2
On 20 Nov 2006 03:44:23 -0800, "Shilpa" <sh***********@gmail.com>
wrote:
>Hi
Can anyone guide me by providing me the code ,for the following
requirement:
how to write a macro for a 16 bit processor that returns the
calculated seconds of a year assuming 365 days in a year ?
In C, macros do not perform calculations. Nor are they functions so
they don't return anything. They serve only two purposes:

They define macro names whose existence can be tested for by
certain preprocessor directives.

They identify text substitutions that are to be performed by the
preprocessor.

Since the maximum value allowed in a 16 bit variable is 65535 and the
number of seconds in a year is on the order of 31.5 million, maybe you
could rephrase your request so we know what you really want.
Remove del for email
Nov 20 '06 #3

Shilpa wrote:
Hi
Can anyone guide me by providing me the code ,for the following
requirement:
how to write a macro for a 16 bit processor that returns the
calculated seconds of a year assuming 365 days in a year ?

Thanking you in advance
There are not 365 days in a year. If you start with a wrong
assumption, you end up with wrong answers.

P.S.
There are 86,400 seconds in a day (ignoring leap seconds)

P.P.S.
If you want the right answer, you can't ignore leap seconds

P.P.P.S.
Leap seconds are pretty rare, I suggest a table lookup.

Nov 20 '06 #4
In article <m9********************************@4ax.com>,
Barry Schwarz <sc******@doezl.netwrote:
>On 20 Nov 2006 03:44:23 -0800, "Shilpa" <sh***********@gmail.com>
wrote:
> how to write a macro for a 16 bit processor that returns the
calculated seconds of a year assuming 365 days in a year ?
>Since the maximum value allowed in a 16 bit variable is 65535 and the
number of seconds in a year is on the order of 31.5 million, maybe you
could rephrase your request so we know what you really want.
On the other hand, a "16 bit processor" is not necessarily
restricted to 16 bit variables -- but it probably would have trouble
if the macro expanded to more than 65535 characters ;-)
--
Prototypes are supertypes of their clones. -- maplesoft
Nov 20 '06 #5
dc*****@connx.com writes:
[...]
There are not 365 days in a year. If you start with a wrong
assumption, you end up with wrong answers.
There are 365 days in *this* year. (The word "year" is ambiguous.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 20 '06 #6
Barry Schwarz wrote:
On 20 Nov 2006 03:44:23 -0800, "Shilpa" <sh***********@gmail.com>
wrote:
Hi
Can anyone guide me by providing me the code ,for the following
requirement:
how to write a macro for a 16 bit processor that returns the
calculated seconds of a year assuming 365 days in a year ?

In C, macros do not perform calculations. Nor are they functions so
they don't return anything. They serve only two purposes:

They define macro names whose existence can be tested for by
certain preprocessor directives.

They identify text substitutions that are to be performed by the
preprocessor.
Hey u r rite in making me understand what a macro is used for. I do
know macros cannot return values, i think i put my question in a wrong
way
Since the maximum value allowed in a 16 bit variable is 65535 and the
number of seconds in a year is on the order of 31.5 million, maybe you
could rephrase your request so we know what you really want.
What I wanted to ask is how to display such a large value in the 16-bit
variables. I guess we have to use array of integers, but how to proceed
after that.
Remove del for email
Nov 21 '06 #7
"Shilpa" <sh***********@gmail.comwrites:
[...]
Hey u r rite in making me understand what a macro is used for.
[...]

Please don't use silly abbreviations like 'u' and 'r' here.
What I wanted to ask is how to display such a large value in the 16-bit
variables. I guess we have to use array of integers, but how to proceed
after that.
A 16-bit variable can only hold 65536 distinct values; if it's a
signed integer, it can't hold a value greater than 32767. But why do
you assume you can only use 16-bit variables? Even on a so-called
"16-bit" machine, C requires for at least 32-bit types (64-bit for
C99).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 21 '06 #8
Shilpa wrote:
Barry Schwarz wrote:
On 20 Nov 2006 03:44:23 -0800, "Shilpa" <sh***********@gmail.com>
wrote:
>Hi
Can anyone guide me by providing me the code ,for the following
>requirement:
how to write a macro for a 16 bit processor that returns the
>calculated seconds of a year assuming 365 days in a year ?
<snip>
Since the maximum value allowed in a 16 bit variable is 65535 and the
number of seconds in a year is on the order of 31.5 million, maybe you
could rephrase your request so we know what you really want.

What I wanted to ask is how to display such a large value in the 16-bit
variables. I guess we have to use array of integers, but how to proceed
after that.
In standard C, the type unsigned long int is atleast 32 bits and so
will be more than sufficient for your purpose.

Nov 21 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MHenry | last post by:
Hi, I know virtually nothing about creating Macros in Access. I would appreciate some help in creating a Macro or Macros that automatically run(s) 14 Queries (three Make Table Queries, and 11...
6
by: Jean | last post by:
Hi, I am using an Access 2000 front-end to an Oracle 9 backend. I want to write a query that returns all records that are not older than one year for Column "Status_30" (which is a Date). ...
3
by: Avin Patel | last post by:
Hi, I have written C# code. And I have used preprocessor / macro in it. I want to get the C# code after processing preprocessor, I have defined durcng compile time. How can I get this code? ...
7
by: alem | last post by:
Alem: hi friends I tried many methods but it will increase or decrease three or four months. Please help me to get exact year and month . thanks in advance.
3
by: PamelaB | last post by:
I am trying to calculate the year end cost basis of equities held. I have downloaded all the transactions (purchases and sales) for the year and have them in a table. I need to calculate the value...
7
by: p0lp0l | last post by:
I'm too dummy. Pls help me... The question: Write a C program that accepts for staff of cOMPANY two data values: monthly salary (ringgit amount) and a character value for performance...
1
by: pyett101 | last post by:
hello everyone. im new to the forum and just started learnign c++ but im stuck with a problem. i want to write a simple program that takes a number of days, hours and minutes and converts them to...
5
by: abhishekmoon007 | last post by:
the program should accept the current date, month and year and should calculate 1 year later date.
0
by: S Kajim | last post by:
Hi there, I need to calculate leap year days between two dates in PL/SQL. Will someone be able to help?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.