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

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

Shilpa
Guest
Posts: n/a

 11-20-2006
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 ?

Richard Bos
Guest
Posts: n/a

 11-20-2006
"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 ?

#define NUMBER_OF_SECONDS_IN_A_SHORT_YEAR 31536000L

HTH; HAND.

Richard

Barry Schwarz
Guest
Posts: n/a

 11-20-2006
On 20 Nov 2006 03:44:23 -0800, "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 ?
>

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

dcorbit@connx.com
Guest
Posts: n/a

 11-20-2006

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 ?
>

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.

Walter Roberson
Guest
Posts: n/a

 11-20-2006
In article <>,
Barry Schwarz <> wrote:
>On 20 Nov 2006 03:44:23 -0800, "Shilpa" <>
>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

Keith Thompson
Guest
Posts: n/a

 11-20-2006
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) kst- <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.

Shilpa
Guest
Posts: n/a

 11-21-2006
Barry Schwarz wrote:
> On 20 Nov 2006 03:44:23 -0800, "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 ?
> >

>
> 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

Keith Thompson
Guest
Posts: n/a

 11-21-2006
"Shilpa" <> writes:
[...]
> 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) kst- <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.

santosh
Guest
Posts: n/a

 11-21-2006
Shilpa wrote:
> Barry Schwarz wrote:
> > On 20 Nov 2006 03:44:23 -0800, "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 ?

<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.