Velocity Reviews > error problems

# error problems

osmium
Guest
Posts: n/a

 02-17-2011
"Bill Cunningham" wrote:

<(E-Mail Removed)> wrote in message
news:4d5da4a5\$0\$4310\$(E-Mail Removed). ..
> osmium wrote:
>
>> Rather than fix the problem you are having, I suggest you rethink your
>> approach.
>>
>> Draw six boxes, representing the six elements of the array known as
>> date. Now, pretend computers used decimal instead of binary, and fill
>> in each of the six boxes as they would look for February 17, 2011.
>> Does the result look sensible to you? I certainly hope not.

>
> My intent was to use a 6 digit format such as 021711. That's why I used
> an array of 6.

Don't use digits, use numbers. 17 is a number, it has two digits, 1 and 7.
It will be much easier to do your computation (later) if you use numbers
instead of digits. You, Bill, will have to provide a carry mechanism with
digits, the computer does it if you use numbers. Month /day/year, a three
element array. I am not saying this is the best method, but it is a big
improvement on what you have now.

Tom St Denis
Guest
Posts: n/a

 02-18-2011
On Feb 17, 6:19*pm, "osmium" <(E-Mail Removed)> wrote:
> "Bill Cunningham" wrote:
> <(E-Mail Removed)> wrote in message
>
> news:4d5da4a5\$0\$4310\$(E-Mail Removed). ..
>
> > osmium wrote:

>
> >> Rather than fix the problem you are having, I suggest you rethink your
> >> approach.

>
> >> Draw six boxes, representing the six elements of the array known as
> >> date. Now, pretend computers used decimal instead of binary, and fill
> >> in each of the six boxes as they would look for February 17, 2011.
> >> Does the result look sensible to you? *I certainly hope not.

>
> > * *My intent was to use a 6 digit format such as 021711. That's why I used
> > an array of 6.

>
> Don't use digits, use numbers. *17 is a number, it has two digits, 1 and 7.
> It will be much easier to do your computation (later) if you use numbers
> instead of digits. *You, Bill, will have to provide a carry mechanism with
> digits, the computer does it if you use numbers. Month /day/year, a three
> element array. I am not saying this is the best method, but it is a big
> improvement on what you have now.

Worse, why not use a POSIX structure compatible with functions like
localtime()/gmtime()/etc.

Tom

Bill Cunningham
Guest
Posts: n/a

 02-18-2011

"Kenneth Brody" <(E-Mail Removed)> wrote in
> Aside from all the other errors, I'm surprised that the compiler doesn't
> warn about the fact that the 2nd and 3rd "return"s will never be reached.
>

Well I didn't use the -Wall -pedantic switches. Maybe I need these in some
kind of looping scheme.

B

Bill Cunningham
Guest
Posts: n/a

 02-18-2011

"osmium" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Bill Cunningham" wrote:
>
> <(E-Mail Removed)> wrote in message
> news:4d5da4a5\$0\$4310\$(E-Mail Removed). ..
>> osmium wrote:
>>
>>> Rather than fix the problem you are having, I suggest you rethink your
>>> approach.
>>>
>>> Draw six boxes, representing the six elements of the array known as
>>> date. Now, pretend computers used decimal instead of binary, and fill
>>> in each of the six boxes as they would look for February 17, 2011.
>>> Does the result look sensible to you? I certainly hope not.

A linked list? Whew. For sorting I could use a std c99 function. I do
want linear sorting around these "boxes". But I'm just getting started.
Stuffing is what concerns me most.

>> My intent was to use a 6 digit format such as 021711. That's why I
>> used an array of 6.

>
> Don't use digits, use numbers. 17 is a number, it has two digits, 1 and
> 7. It will be much easier to do your computation (later) if you use
> numbers instead of digits. You, Bill, will have to provide a carry
> mechanism

A carry mechanism?

with
> digits, the computer does it if you use numbers. Month /day/year, a three
> element array. I am not saying this is the best method, but it is a big
> improvement on what you have now.
>

osmium
Guest
Posts: n/a

 02-18-2011
"Bill Cunningham" wrote:

> "osmium" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> "Bill Cunningham" wrote:
>>
>> <(E-Mail Removed)> wrote in message
>> news:4d5da4a5\$0\$4310\$(E-Mail Removed). ..
>>> osmium wrote:
>>>
>>>> Rather than fix the problem you are having, I suggest you rethink your
>>>> approach.
>>>>
>>>> Draw six boxes, representing the six elements of the array known as
>>>> date. Now, pretend computers used decimal instead of binary, and fill
>>>> in each of the six boxes as they would look for February 17, 2011.
>>>> Does the result look sensible to you? I certainly hope not.

>
> A linked list? Whew. For sorting I could use a std c99 function. I do
> want linear sorting around these "boxes". But I'm just getting started.
> Stuffing is what concerns me most.

Where does the linked list come from? I didn't say or imply anything

>>> My intent was to use a 6 digit format such as 021711. That's why I
>>> used an array of 6.

>>
>> Don't use digits, use numbers. 17 is a number, it has two digits, 1 and
>> 7. It will be much easier to do your computation (later) if you use
>> numbers instead of digits. You, Bill, will have to provide a carry
>> mechanism

>
> A carry mechanism?

17+5 = 22, the left digit changes from 1 to 2 because of a carry. You said
there is. If you treat the 7 as an element of an array, you must provide a
carry if you want to add to the 7.

One of the better answers you were given last week was to use the facilities
in <time.h> but you chose to ignore that suggestion, for reasons known only
to you, and go your own way.

If you decide to use a POSIX oriented solution, move your thread to a news
group appropriate for talking about POSIX, this is not such a group.

Mickey Mouse
Guest
Posts: n/a

 02-18-2011
On Thu, 17 Feb 2011 21:42:29 -0800, Jonathan Leffler
<(E-Mail Removed)> wrote:

>On 2/17/11 3:11 PM, Sherm Pendley wrote:
>> "Bill Cunningham"<(E-Mail Removed)> writes:
>>
>>> My intent was to use a 6 digit format such as 021711.

>>
>> Please tell me you're joking... I thought the whole world learned that
>> lesson over a decade ago!
>>
>> <http://en.wikipedia.org/wiki/Y2K_problem>

>
>The world has had 10 years to forget - and has successfully forgotten.
>

I use "YYYYMMDD" as a 32 bit number, seems to work for all I have
needed. Sorts nicely as well.

Bill Cunningham
Guest
Posts: n/a

 02-18-2011
osmium wrote:

[snip]

> Where does the linked list come from? I didn't say or imply anything

It sounded to me like what you was suggesting might be well done by a
linked list. There was no suggestion by you. I have trouble with that
algorithm.

>>>> My intent was to use a 6 digit format such as 021711. That's
>>>> why I used an array of 6.
>>>
>>> Don't use digits, use numbers. 17 is a number, it has two digits,
>>> 1 and 7. It will be much easier to do your computation (later) if you
>>> use
>>> numbers instead of digits. You, Bill, will have to provide a carry
>>> mechanism

>>
>> A carry mechanism?

>
> 17+5 = 22, the left digit changes from 1 to 2 because of a carry. You
> simplest computation there is. If you treat the 7 as an element of
> an array, you must provide a carry if you want to add to the 7.

I'm not quite sure I understand. I will give this some thought though.

> One of the better answers you were given last week was to use the
> facilities in <time.h> but you chose to ignore that suggestion, for
> reasons known only to you, and go your own way.

If I wanted to add yesterdays data today, would time.h be a very good
way to go? I keep track of friday's data. Sometimes I add it on saturdays.
Does this make sense?

> If you decide to use a POSIX oriented solution, move your thread to
> a news group appropriate for talking about POSIX, this is not such a
> group.

Understood.

B

James Waldby
Guest
Posts: n/a

 02-18-2011
On Fri, 18 Feb 2011 17:19:59 -0500, Bill Cunningham wrote:
> osmium wrote:

....
>>>>> My intent was to use a 6 digit format such as 021711. That's
>>>>> why I used an array of 6.
>>>>
>>>> Don't use digits, use numbers. 17 is a number, it has two digits, 1
>>>> and 7. It will be much easier to do your computation (later) if you
>>>> use numbers instead of digits. You, Bill, will have to provide
>>>> a carry mechanism
>>>
>>> A carry mechanism?

>>
>> 17+5 = 22, the left digit changes from 1 to 2 because of a carry. You
>> said earlier you wanted to compute. Addition is about the simplest
>> computation there is. If you treat the 7 as an element of an array,
>> you must provide a carry if you want to add to the 7.

>
> I'm not quite sure I understand. I will give this some thought
> though.

Dates, times, or dates+times can be represented several different
ways in a computer. Choice of representation affects what is easy
to do with them.

With the date representation you mentioned (six characters or digits
for mmddyy) it is easy to do input and output but less easy to do
arithmetic (such as the amount of time between two dates, or what
day is 180 days after a date). To do such arithmetic, you may need
to compute carries; for example, "021811" + 14 days = "030311".

With date represented in an object of type time_t as defined by
the <time.h> header file it is easy to do date arithmetic (the
time_t type typically is like a 32-bit or 64-bit integer type)
and using routines mentioned in next paragraph it isn't difficult
to do input and output.

See <http://en.wikipedia.org/wiki/Time_t> for a time_t example.
Also read man pages for routines declared in <time.h>: clock(),
time(), difftime(), mktime(), strftime(), strptime(), gmtime(),
asctime(), ctime(), and reentrant versions of same. These
address the time-handling problems that people find it useful
to address, and using them may help avoid errors.

>> One of the better answers you were given last week was to use the
>> facilities in <time.h> but you chose to ignore that suggestion, for
>> reasons known only to you, and go your own way.

>
> If I wanted to add yesterdays data today, would time.h be a very
> good way to go? I keep track of friday's data. Sometimes I add
> it on saturdays. Does this make sense?

....

--
jiw

Jorgen Grahn
Guest
Posts: n/a

 02-19-2011
On Fri, 2011-02-18, Tom St Denis wrote:
> On Feb 17, 6:19*pm, "osmium" <(E-Mail Removed)> wrote:
>> "Bill Cunningham" wrote:
>> <(E-Mail Removed)> wrote in message
>>
>> news:4d5da4a5\$0\$4310\$(E-Mail Removed). ..
>>
>> > osmium wrote:

>>
>> >> Rather than fix the problem you are having, I suggest you rethink your
>> >> approach.

>>
>> >> Draw six boxes, representing the six elements of the array known as
>> >> date. Now, pretend computers used decimal instead of binary, and fill
>> >> in each of the six boxes as they would look for February 17, 2011.
>> >> Does the result look sensible to you? *I certainly hope not.

>>
>> > * *My intent was to use a 6 digit format such as 021711. That's why I used
>> > an array of 6.

>>
>> Don't use digits, use numbers. *17 is a number, it has two digits, 1 and 7.
>> It will be much easier to do your computation (later) if you use numbers
>> instead of digits. *You, Bill, will have to provide a carry mechanism with
>> digits, the computer does it if you use numbers. Month /day/year, a three
>> element array. I am not saying this is the best method, but it is a big
>> improvement on what you have now.

>
> Worse, why not use a POSIX structure compatible with functions like
> localtime()/gmtime()/etc.

You'd have to be a bit careful to do that. A date isn't a time_t; the
same time_t can be different dates depending on your time zone.
You wouldn't want your software to break as soon as someone uses it in
New Zealand ...

I'd avoid local time, and let 2011-02-19 be represented by 2011-02-19
00:00:00 GMT. That should be workable.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Ian Collins
Guest
Posts: n/a

 02-19-2011
On 02/19/11 01:32 PM, Jorgen Grahn wrote:
> On Fri, 2011-02-18, Tom St Denis wrote:
>>
>> Worse, why not use a POSIX structure compatible with functions like
>> localtime()/gmtime()/etc.

>
> You'd have to be a bit careful to do that. A date isn't a time_t; the
> same time_t can be different dates depending on your time zone.
> You wouldn't want your software to break as soon as someone uses it in
> New Zealand ...

Well I live in NZ and coincidentally I did have some time/date code I
wrote on a trip to Europe fail when got home - a UTC time that was
Sunday in Spain was Monday here!

--
Ian Collins