Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #14217 > unrolled thread

casting constant value from float to unsigned short - compiler bugs?

Started by"news.aon.at" <mario_semo@hotmail.com>
First post2011-12-02 10:06 +0100
Last post2011-12-02 16:26 +0100
Articles 20 on this page of 46 — 18 participants

Back to article view | Back to comp.lang.c


Contents

  casting constant value from float to unsigned short - compiler bugs? "news.aon.at" <mario_semo@hotmail.com> - 2011-12-02 10:06 +0100
    Re: casting constant value from float to unsigned short - compiler bugs? jacob navia <jacob@spamsink.net> - 2011-12-02 10:34 +0100
      Re: casting constant value from float to unsigned short - compiler bugs? Vincenzo Mercuri <vincenzo.mercuri@hotmail.it> - 2011-12-02 18:10 +0100
      Re: casting constant value from float to unsigned short - compiler bugs? Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2011-12-02 22:36 +0000
        Re: casting constant value from float to unsigned short - compiler bugs? jacob navia <jacob@spamsink.net> - 2011-12-03 00:45 +0100
          Re: casting constant value from float to unsigned short - compiler  bugs? pete <pfiland@mindspring.com> - 2011-12-02 19:43 -0500
            Re: casting constant value from float to unsigned short - compiler   bugs? pete <pfiland@mindspring.com> - 2011-12-02 19:49 -0500
          Re: casting constant value from float to unsigned short - compiler bugs? Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-12-03 01:51 +0100
            Re: casting constant value from float to unsigned short - compiler bugs? James Kuyper <jameskuyper@verizon.net> - 2011-12-03 11:51 -0500
              Re: casting constant value from float to unsigned short - compiler bugs? Vincenzo Mercuri <vincenzo.mercuri@hotmail.it> - 2011-12-03 19:08 +0100
                Re: casting constant value from float to unsigned short - compiler bugs? Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2011-12-03 19:06 +0000
                  Re: casting constant value from float to unsigned short - compiler bugs? Kaz Kylheku <kaz@kylheku.com> - 2011-12-03 19:14 +0000
                  Re: casting constant value from float to unsigned short - compiler bugs? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-12-04 17:19 +0200
                    Re: casting constant value from float to unsigned short - compiler bugs? James Kuyper <jameskuyper@verizon.net> - 2011-12-04 10:39 -0500
        Re: casting constant value from float to unsigned short - compiler bugs? Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-12-03 01:41 +0100
          Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-03 12:31 -0800
            Re: casting constant value from float to unsigned short - compiler bugs? blp@cs.stanford.edu (Ben Pfaff) - 2012-01-03 12:38 -0800
              Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-06 11:38 -0800
                Re: casting constant value from float to unsigned short - compiler bugs? James Kuyper <jameskuyper@verizon.net> - 2012-01-06 15:10 -0500
            Re: casting constant value from float to unsigned short - compiler bugs? Keith Thompson <kst-u@mib.org> - 2012-01-03 12:49 -0800
              Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-04 15:14 -0800
                Re: casting constant value from float to unsigned short - compiler bugs? James Kuyper <jameskuyper@verizon.net> - 2012-01-04 19:12 -0500
                  Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-04 23:04 -0800
                    Re: casting constant value from float to unsigned short - compiler bugs? Keith Thompson <kst-u@mib.org> - 2012-01-05 02:43 -0800
                      Re: casting constant value from float to unsigned short - compiler bugs? James Kuyper <jameskuyper@verizon.net> - 2012-01-05 07:14 -0500
                        Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-06 11:39 -0800
                      Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-05 16:14 -0800
                        Re: casting constant value from float to unsigned short - compiler bugs? Keith Thompson <kst-u@mib.org> - 2012-01-05 16:44 -0800
                          Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-06 11:30 -0800
                            Re: casting constant value from float to unsigned short - compiler bugs? James Kuyper <jameskuyper@verizon.net> - 2012-01-06 15:24 -0500
                            Re: casting constant value from float to unsigned short - compiler bugs? Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-26 09:14 -0800
                Re: casting constant value from float to unsigned short - compiler bugs? gwowen <gwowen@gmail.com> - 2012-01-05 04:09 -0800
                Re: casting constant value from float to unsigned short - compiler bugs? "io_x" <a@b.c.invalid> - 2012-01-05 16:32 +0100
            Re: casting constant value from float to unsigned short - compiler bugs? Nobody <nobody@nowhere.com> - 2012-01-04 09:11 +0000
              Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-04 23:08 -0800
                Re: casting constant value from float to unsigned short - compiler bugs? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-05 11:15 +0000
                  Re: casting constant value from float to unsigned short - compiler bugs? James Kuyper <jameskuyper@verizon.net> - 2012-01-05 07:27 -0500
                    Re: casting constant value from float to unsigned short - compiler bugs? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-05 13:03 +0000
                    Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-05 16:28 -0800
                      Re: casting constant value from float to unsigned short - compiler bugs? James Kuyper <jameskuyper@verizon.net> - 2012-01-06 07:17 -0500
                      Re: casting constant value from float to unsigned short - compiler bugs? lawrence.jones@siemens.com - 2012-01-06 12:04 -0500
                    Re: casting constant value from float to unsigned short - compiler bugs? Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-26 09:08 -0800
                  Re: casting constant value from float to unsigned short - compiler bugs? Michael Press <rubrum@pacbell.net> - 2012-01-05 16:17 -0800
        Re: casting constant value from float to unsigned short - compiler bugs? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-03 01:50 +0000
    Re: casting constant value from float to unsigned short - compiler bugs? James Kuyper <jameskuyper@verizon.net> - 2011-12-02 06:41 -0500
      Re: casting constant value from float to unsigned short - compiler bugs? Vincenzo Mercuri <vincenzo.mercuri@hotmail.it> - 2011-12-02 16:26 +0100

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#15423

FromMichael Press <rubrum@pacbell.net>
Date2012-01-04 15:14 -0800
Message-ID<rubrum-8407B2.15141404012012@news.albasani.net>
In reply to#15385
In article <lnmxa45x6c.fsf@nuthaus.mib.org>,
 Keith Thompson <kst-u@mib.org> wrote:

> Michael Press <rubrum@pacbell.net> writes:
> > In article <f_ydnS3uiPzU7UTTnZ2dnUVZ8lqdnZ2d@giganews.com>,
> >  Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> wrote:
> >
> >> p1:
> >>       When a finite value of real floating type is converted to an
> >>       integer type other than _Bool, the fractional part is discarded
> >>       (i.e., the value is truncated toward zero). If the value of the
> >>       integral part cannot be represented by the integer type,
> >>       the behavior is undefined.[^50]
> >
> > Note that this wording is at variance with standard mathematcal definitions.
> >
> > The floor function is defined as
> >
> >     floor(x) = maximum integer m such that m <= x.
> >
> > Hence floor(x) <= x.
> 
> Yes, and that's consistent with the C standard's floor(), floorf(),
> and floorl() functions in <math.h>.
> 
> > The fractional part of x is defined to be
> >
> >     frac(x) = x - floor(x).
> >
> > Hence frac(x) >= 0.
> 
> Can you cite a source that says that that's what "fractional part"
> means in mathematics?

Yes. Why? Do you have a source that states otherwise?




















































































































Knuth, ACP, 1.2.4.

Oxford Dictionary of Mathematics
<http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>

-- 
Michael Press

[toc] | [prev] | [next] | [standalone]


#15432

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-01-04 19:12 -0500
Message-ID<4F04EB0B.60701@verizon.net>
In reply to#15423
On 01/04/2012 06:14 PM, Michael Press wrote:
> In article <lnmxa45x6c.fsf@nuthaus.mib.org>,
>  Keith Thompson <kst-u@mib.org> wrote:
> 
>> Michael Press <rubrum@pacbell.net> writes:
...
>>> The floor function is defined as
>>>
>>>     floor(x) = maximum integer m such that m <= x.
>>>
>>> Hence floor(x) <= x.
>>
>> Yes, and that's consistent with the C standard's floor(), floorf(),
>> and floorl() functions in <math.h>.
>>
>>> The fractional part of x is defined to be
>>>
>>>     frac(x) = x - floor(x).
>>>
>>> Hence frac(x) >= 0.
>>
>> Can you cite a source that says that that's what "fractional part"
>> means in mathematics?
> 
> Yes. Why? Do you have a source that states otherwise?

At the time Keith posted, Ben Pfaff had already given a URL for a
Mathematica web site indicating that "Spanier and Oldham (1987) use the
same definition as Mathematica", which is (probably not coincidentally)
the same as C's definition.

...
[snip 116 blank lines]
What was the purpose of those blank lines?

> Knuth, ACP, 1.2.4.
> 
> Oxford Dictionary of Mathematics
> <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>

[toc] | [prev] | [next] | [standalone]


#15451

FromMichael Press <rubrum@pacbell.net>
Date2012-01-04 23:04 -0800
Message-ID<rubrum-21FF7A.23042704012012@news.albasani.net>
In reply to#15432
In article <4F04EB0B.60701@verizon.net>,
 James Kuyper <jameskuyper@verizon.net> wrote:

> On 01/04/2012 06:14 PM, Michael Press wrote:
> > In article <lnmxa45x6c.fsf@nuthaus.mib.org>,
> >  Keith Thompson <kst-u@mib.org> wrote:
> > 
> >> Michael Press <rubrum@pacbell.net> writes:
> ...
> >>> The floor function is defined as
> >>>
> >>>     floor(x) = maximum integer m such that m <= x.
> >>>
> >>> Hence floor(x) <= x.
> >>
> >> Yes, and that's consistent with the C standard's floor(), floorf(),
> >> and floorl() functions in <math.h>.
> >>
> >>> The fractional part of x is defined to be
> >>>
> >>>     frac(x) = x - floor(x).
> >>>
> >>> Hence frac(x) >= 0.
> >>
> >> Can you cite a source that says that that's what "fractional part"
> >> means in mathematics?
> > 
> > Yes. Why? Do you have a source that states otherwise?
> 
> At the time Keith posted, Ben Pfaff had already given a URL for a
> Mathematica web site indicating that "Spanier and Oldham (1987) use the
> same definition as Mathematica", which is (probably not coincidentally)
> the same as C's definition.
> 
> ...
> [snip 116 blank lines]
> What was the purpose of those blank lines?

I will wait until Keith asks.

> 
> > Knuth, ACP, 1.2.4.
> > 
> > Oxford Dictionary of Mathematics
> > <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>

-- 
Michael Press

[toc] | [prev] | [next] | [standalone]


#15457

FromKeith Thompson <kst-u@mib.org>
Date2012-01-05 02:43 -0800
Message-ID<lnehve5t0b.fsf@nuthaus.mib.org>
In reply to#15451
Michael Press <rubrum@pacbell.net> writes:
> In article <4F04EB0B.60701@verizon.net>,
>  James Kuyper <jameskuyper@verizon.net> wrote:
>> On 01/04/2012 06:14 PM, Michael Press wrote:
>> > In article <lnmxa45x6c.fsf@nuthaus.mib.org>,
>> >  Keith Thompson <kst-u@mib.org> wrote:
>> >> Michael Press <rubrum@pacbell.net> writes:
[...]
>> >>> Hence frac(x) >= 0.
>> >>
>> >> Can you cite a source that says that that's what "fractional part"
>> >> means in mathematics?
>> > 
>> > Yes. Why? Do you have a source that states otherwise?
>> 
>> At the time Keith posted, Ben Pfaff had already given a URL for a
>> Mathematica web site indicating that "Spanier and Oldham (1987) use the
>> same definition as Mathematica", which is (probably not coincidentally)
>> the same as C's definition.
>> 
>> ...
>> [snip 116 blank lines]
>> What was the purpose of those blank lines?
>
> I will wait until Keith asks.

Ok, what was the purpose of those blank lines?  And why would you feel
the need to wait until I ask about it?

When I read your response, I didn't even realize that those blank lines
were there.  I went to the next article thinking that you had said that
you have a source but weren't going to share it (and was about to remark
on that.

My working hypothesis is that you were being deliberately difficult.

>> > Knuth, ACP, 1.2.4.
>> > 
>> > Oxford Dictionary of Mathematics
>> > <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>

Ok.  My point is that "mathematics" is a very large field, and I'm
skeptical that there's a single definition for a term like "fractional
part" that all mathematicians would accept.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#15460

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-01-05 07:14 -0500
Message-ID<je4485$b3i$1@dont-email.me>
In reply to#15457
On 01/05/2012 05:43 AM, Keith Thompson wrote:
> Michael Press <rubrum@pacbell.net> writes:
>> In article <4F04EB0B.60701@verizon.net>,
>>  James Kuyper <jameskuyper@verizon.net> wrote:
...
>>> [snip 116 blank lines]
>>> What was the purpose of those blank lines?
>>
>> I will wait until Keith asks.
> 
> Ok, what was the purpose of those blank lines?  And why would you feel
> the need to wait until I ask about it?
> 
> When I read your response, I didn't even realize that those blank lines
> were there.  I went to the next article thinking that you had said that
> you have a source but weren't going to share it (and was about to remark
> on that.

That was my initial reaction, too, and I presume that provoking that
reaction was the purpose of those lines. However, that doesn't quite
make sense: anyone who decided to post a response complaining about the
lack of a specific citation would immediately notice it, unless they
made the mistake of top-posting.

> My working hypothesis is that you were being deliberately difficult.

Agreed.

>>>> Knuth, ACP, 1.2.4.
>>>>
>>>> Oxford Dictionary of Mathematics
>>>> <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>
> 
> Ok.  My point is that "mathematics" is a very large field, and I'm
> skeptical that there's a single definition for a term like "fractional
> part" that all mathematicians would accept.

I'm basically in agreement with you on that, but playing the Devil's
Advocate for a moment, I have to concede that his citation seems
significantly more authoritative than Ben's.
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#15493

FromMichael Press <rubrum@pacbell.net>
Date2012-01-06 11:39 -0800
Message-ID<rubrum-C426E3.11394906012012@news.albasani.net>
In reply to#15460
In article <je4485$b3i$1@dont-email.me>,
 James Kuyper <jameskuyper@verizon.net> wrote:

> On 01/05/2012 05:43 AM, Keith Thompson wrote:
> > Michael Press <rubrum@pacbell.net> writes:
> >> In article <4F04EB0B.60701@verizon.net>,
> >>  James Kuyper <jameskuyper@verizon.net> wrote:
> ...
> >>> [snip 116 blank lines]
> >>> What was the purpose of those blank lines?
> >>
> >> I will wait until Keith asks.
> > 
> > Ok, what was the purpose of those blank lines?  And why would you feel
> > the need to wait until I ask about it?
> > 
> > When I read your response, I didn't even realize that those blank lines
> > were there.  I went to the next article thinking that you had said that
> > you have a source but weren't going to share it (and was about to remark
> > on that.
> 
> That was my initial reaction, too, and I presume that provoking that
> reaction was the purpose of those lines. However, that doesn't quite
> make sense: anyone who decided to post a response complaining about the
> lack of a specific citation would immediately notice it, unless they
> made the mistake of top-posting.
> 
> > My working hypothesis is that you were being deliberately difficult.
> 
> Agreed.
> 
> >>>> Knuth, ACP, 1.2.4.
> >>>>
> >>>> Oxford Dictionary of Mathematics
> >>>> <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>
> > 
> > Ok.  My point is that "mathematics" is a very large field, and I'm
> > skeptical that there's a single definition for a term like "fractional
> > part" that all mathematicians would accept.
> 
> I'm basically in agreement with you on that, but playing the Devil's
> Advocate 

Flatterer. 

> for a moment, I have to concede that his citation seems
> significantly more authoritative than Ben's.

-- 
Michael Press

[toc] | [prev] | [next] | [standalone]


#15476

FromMichael Press <rubrum@pacbell.net>
Date2012-01-05 16:14 -0800
Message-ID<rubrum-1950AD.16142705012012@news.albasani.net>
In reply to#15457
In article <lnehve5t0b.fsf@nuthaus.mib.org>,
 Keith Thompson <kst-u@mib.org> wrote:

> Michael Press <rubrum@pacbell.net> writes:
> > In article <4F04EB0B.60701@verizon.net>,
> >  James Kuyper <jameskuyper@verizon.net> wrote:
> >> On 01/04/2012 06:14 PM, Michael Press wrote:
> >> > In article <lnmxa45x6c.fsf@nuthaus.mib.org>,
> >> >  Keith Thompson <kst-u@mib.org> wrote:
> >> >> Michael Press <rubrum@pacbell.net> writes:
> [...]
> >> >>> Hence frac(x) >= 0.
> >> >>
> >> >> Can you cite a source that says that that's what "fractional part"
> >> >> means in mathematics?
> >> > 
> >> > Yes. Why? Do you have a source that states otherwise?
> >> 
> >> At the time Keith posted, Ben Pfaff had already given a URL for a
> >> Mathematica web site indicating that "Spanier and Oldham (1987) use the
> >> same definition as Mathematica", which is (probably not coincidentally)
> >> the same as C's definition.
> >> 
> >> ...
> >> [snip 116 blank lines]
> >> What was the purpose of those blank lines?
> >
> > I will wait until Keith asks.
> 
> Ok, what was the purpose of those blank lines?  

The purpose is to allow you time to realize you asked
a yes-no question; and I answered it. Then I graciously
supplied you with citations. 

> And why would you feel
> the need to wait until I ask about it?

In case you are not interested. 
It is what I think, not feel.

> When I read your response, I didn't even realize that those blank lines
> were there.  I went to the next article thinking that you had said that
> you have a source but weren't going to share it (and was about to remark
> on that.

You asked a yes-no question. 
Did you realize that?

> My working hypothesis is that you were being deliberately difficult.

I was and am.

> >> > Knuth, ACP, 1.2.4.
> >> > 
> >> > Oxford Dictionary of Mathematics
> >> > <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>
> 
> Ok.  My point is that "mathematics" is a very large field, and I'm
> skeptical that there's a single definition for a term like "fractional
> part" that all mathematicians would accept.

Oh ho. You are not interested in this; and are wasting my time,
else you would present cogent arguments.

-- 
Michael Press

[toc] | [prev] | [next] | [standalone]


#15479

FromKeith Thompson <kst-u@mib.org>
Date2012-01-05 16:44 -0800
Message-ID<ln62gp64nt.fsf@nuthaus.mib.org>
In reply to#15476
Michael Press <rubrum@pacbell.net> writes:
> In article <lnehve5t0b.fsf@nuthaus.mib.org>,
>  Keith Thompson <kst-u@mib.org> wrote:
[...]
>> My working hypothesis is that you were being deliberately difficult.
>
> I was and am.

Why?

I was trying to have a constructive technical discussion.  If you're
not interested in that, I won't waste my time with you.

>> >> > Knuth, ACP, 1.2.4.
>> >> > 
>> >> > Oxford Dictionary of Mathematics
>> >> > <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>
>> 
>> Ok.  My point is that "mathematics" is a very large field, and I'm
>> skeptical that there's a single definition for a term like "fractional
>> part" that all mathematicians would accept.
>
> Oh ho. You are not interested in this; and are wasting my time,
> else you would present cogent arguments.

In fact I am interested in this.  You made a specific claim; I asked you
to support it.  Someone interested in actual discussion wouldn't have
made such a big deal about the fact that my question was literally a
yes/no question; it was clearly intended to solicit more useful
information.

My argument above was certainly intended to be "cogent".  If you didn't
find it so, feel free to elaborate.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#15491

FromMichael Press <rubrum@pacbell.net>
Date2012-01-06 11:30 -0800
Message-ID<rubrum-F94ABB.11300606012012@news.albasani.net>
In reply to#15479
In article <ln62gp64nt.fsf@nuthaus.mib.org>,
 Keith Thompson <kst-u@mib.org> wrote:

> Michael Press <rubrum@pacbell.net> writes:
> > In article <lnehve5t0b.fsf@nuthaus.mib.org>,
> >  Keith Thompson <kst-u@mib.org> wrote:
> [...]
> >> My working hypothesis is that you were being deliberately difficult.
> >
> > I was and am.
> 
> Why?
> 
> I was trying to have a constructive technical discussion.  If you're
> not interested in that, I won't waste my time with you.
> 
> >> >> > Knuth, ACP, 1.2.4.
> >> >> > 
> >> >> > Oxford Dictionary of Mathematics
> >> >> > <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>
> >> 
> >> Ok.  My point is that "mathematics" is a very large field, and I'm
> >> skeptical that there's a single definition for a term like "fractional
> >> part" that all mathematicians would accept.
> >
> > Oh ho. You are not interested in this; and are wasting my time,
> > else you would present cogent arguments.
> 
> In fact I am interested in this.  You made a specific claim; I asked you
> to support it.  Someone interested in actual discussion wouldn't have
> made such a big deal about the fact that my question was literally a
> yes/no question; it was clearly intended to solicit more useful
> information.
> 
> My argument above was certainly intended to be "cogent".  If you didn't
> find it so, feel free to elaborate.

You offer a meta-argument about mathematics,
rather than mathematical arguments. That
is hand waving. 

For instance: the definition of prime
number once included 1 as a prime.
Eventually this definition made 
statements and proofs of theorems
awkward. Changing the definition
made theorem statements and proofs 
smoother and easier to follow. 

frac(x) = x - floor(x) is simpler
to write than the alternative. 
The standard definition is periodic
and that is a neat property to have.

The definition of equidistributed sequence is easier.
A sequence {a_n} is equidistributed
if {frac(a_n)} is equidistributed in [0,1].

The truncation toward zero definition does not
make mathematics easier. 

argumentum ad verecundiam:
Donald Knuth uses this definition.

-- 
Michael Press

[toc] | [prev] | [next] | [standalone]


#15496

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-01-06 15:24 -0500
Message-ID<4F07586E.70506@verizon.net>
In reply to#15491
On 01/06/2012 02:30 PM, Michael Press wrote:
> In article <ln62gp64nt.fsf@nuthaus.mib.org>,
>  Keith Thompson <kst-u@mib.org> wrote:
> 
>> Michael Press <rubrum@pacbell.net> writes:
>>> In article <lnehve5t0b.fsf@nuthaus.mib.org>,
>>>  Keith Thompson <kst-u@mib.org> wrote:
...
>>>> Ok.  My point is that "mathematics" is a very large field, and I'm
>>>> skeptical that there's a single definition for a term like "fractional
>>>> part" that all mathematicians would accept.
>>>
>>> Oh ho. You are not interested in this; and are wasting my time,
>>> else you would present cogent arguments.
>>
>> In fact I am interested in this.  You made a specific claim; I asked you
>> to support it.  Someone interested in actual discussion wouldn't have
>> made such a big deal about the fact that my question was literally a
>> yes/no question; it was clearly intended to solicit more useful
>> information.
>>
>> My argument above was certainly intended to be "cogent".  If you didn't
>> find it so, feel free to elaborate.
> 
> You offer a meta-argument about mathematics,
> rather than mathematical arguments. That
> is hand waving. 
> 
> For instance: the definition of prime
> number once included 1 as a prime.
> Eventually this definition made 
> statements and proofs of theorems
> awkward. Changing the definition
> made theorem statements and proofs 
> smoother and easier to follow. 
> 
> frac(x) = x - floor(x) is simpler
> to write than the alternative. 
> The standard definition is periodic
> and that is a neat property to have.
> 
> The definition of equidistributed sequence is easier.
> A sequence {a_n} is equidistributed
> if {frac(a_n)} is equidistributed in [0,1].
> 
> The truncation toward zero definition does not
> make mathematics easier. 
> 
> argumentum ad verecundiam:
> Donald Knuth uses this definition.

Facts like that would be relevant, if the question Keith were discussing
were "what should the mathematical definition of 'fractional part' be?".
The question he was actually discussing was "Is there a definition for
'fractional part' that is so widely accepted by mathematicians, that it
can reasonably be referred to as 'the' mathematical definition?".

The benefits and disadvantages of various possible definitions are very
relevant to the first question, and completely irrelevant to the second
one. Identifying people who use various definitions for 'fractional
part', and assessing their degree of influence in the mathematical
community, should be irrelevant to the first question, but is very
relevant to the second one.

The wording used in the standard is quite reasonable if the answer to
the second question is "No", while the answer to the first question is
quite irrelevant. The behavior defined by the standard was chosen to
match common existing usage, not because of any of the issues you raise
above. The only legitimate issue is about how to correctly describe that
behavior.

[toc] | [prev] | [next] | [standalone]


#16262

FromTim Rentsch <txr@alumni.caltech.edu>
Date2012-01-26 09:14 -0800
Message-ID<kfnmx9a2xol.fsf@x-alumni2.alumni.caltech.edu>
In reply to#15491
Michael Press <rubrum@pacbell.net> writes:

> In article <ln62gp64nt.fsf@nuthaus.mib.org>,
>  Keith Thompson <kst-u@mib.org> wrote:
>
>> Michael Press <rubrum@pacbell.net> writes:
>> > In article <lnehve5t0b.fsf@nuthaus.mib.org>,
>> >  Keith Thompson <kst-u@mib.org> wrote:
>> [...]
>> >> My working hypothesis is that you were being deliberately difficult.
>> >
>> > I was and am.
>> 
>> Why?
>> 
>> I was trying to have a constructive technical discussion.  If you're
>> not interested in that, I won't waste my time with you.
>> 
>> >> >> > Knuth, ACP, 1.2.4.
>> >> >> > 
>> >> >> > Oxford Dictionary of Mathematics
>> >> >> > <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=Dictionary+mathematics+fractional+part+-function&source=bl&ots=ezjia_b9uW&sig=Tojsd5nB2_gcZixDfGfB8SRVjAo&hl=en>
>> >> 
>> >> Ok.  My point is that "mathematics" is a very large field, and I'm
>> >> skeptical that there's a single definition for a term like "fractional
>> >> part" that all mathematicians would accept.
>> >
>> > Oh ho. You are not interested in this; and are wasting my time,
>> > else you would present cogent arguments.
>> 
>> In fact I am interested in this.  You made a specific claim; I asked you
>> to support it.  Someone interested in actual discussion wouldn't have
>> made such a big deal about the fact that my question was literally a
>> yes/no question; it was clearly intended to solicit more useful
>> information.
>> 
>> My argument above was certainly intended to be "cogent".  If you didn't
>> find it so, feel free to elaborate.
>
> You offer a meta-argument about mathematics,
> rather than mathematical arguments. That
> is hand waving.   [snip]

Just an observation here -- you are also.

[toc] | [prev] | [next] | [standalone]


#15464

Fromgwowen <gwowen@gmail.com>
Date2012-01-05 04:09 -0800
Message-ID<0b694e22-2c1e-4b9a-81eb-63d766ffeede@t16g2000vba.googlegroups.com>
In reply to#15423
On Jan 4, 11:14 pm, Michael Press <rub...@pacbell.net> wrote:

> Yes. Why? Do you have a source that states otherwise?
>
> Knuth, ACP, 1.2.4.
>
> Oxford Dictionary of Mathematics
> <http://books.google.com/books?id=UTCenrlmVW4C&pg=PT192&lpg=PT192&dq=D...>

Interesting that using the definition of "Integer Part" from MathWorld
or PlanetMath invalidates this definition.

Perhaps more interesting is MathWorld's comment on the fractional
part: "Unfortunately, there is no universal agreement on the meaning
of frac(x) for x<0 and there are two common definitions"

http://mathworld.wolfram.com/IntegerPart.html
http://planetmath.org/encyclopedia/IntegerPart.html
http://mathworld.wolfram.com/FractionalPart.html

[toc] | [prev] | [next] | [standalone]


#15467

From"io_x" <a@b.c.invalid>
Date2012-01-05 16:32 +0100
Message-ID<4f05c194$0$1375$4fafbaef@reader2.news.tin.it>
In reply to#15423
"Michael Press" <rubrum@pacbell.net> ha scritto nel messaggio 
news:rubrum-8407B2.15141404012012@news.albasani.net...
> In article <lnmxa45x6c.fsf@nuthaus.mib.org>,
> Keith Thompson <kst-u@mib.org> wrote:
>
>> Michael Press <rubrum@pacbell.net> writes:
>> > In article <f_ydnS3uiPzU7UTTnZ2dnUVZ8lqdnZ2d@giganews.com>,
>> >  Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> wrote:
>> >
>> >> p1:
>> >>       When a finite value of real floating type is converted to an
>> >>       integer type other than _Bool, the fractional part is discarded
>> >>       (i.e., the value is truncated toward zero). If the value of the
>> >>       integral part cannot be represented by the integer type,
>> >>       the behavior is undefined.[^50]
>> >
>> > Note that this wording is at variance with standard mathematcal 
>> > definitions.
>> >
>> > The floor function is defined as
>> >
>> >     floor(x) = maximum integer m such that m <= x.
>> >
>> > Hence floor(x) <= x.
>>
>> Yes, and that's consistent with the C standard's floor(), floorf(),
>> and floorl() functions in <math.h>.
>>
>> > The fractional part of x is defined to be
>> >
>> >     frac(x) = x - floor(x).
>> >
>> > Hence frac(x) >= 0.
>>
>> Can you cite a source that says that that's what "fractional part"
>> means in mathematics?
>
> Yes. Why? Do you have a source that states otherwise?

one can accept all
because definitions shines in application...

for the book of math "Analisi Matematica" Vol 1 i studied
the integer part of xeR is
int(x)=[x]=max{y: yeZ /\ y<=x}
"parte intera di x, come il più grande intero che non supera x"
this would mean [2]=2 [2.9]=2 [-2]=-2  [-2.8]=-3
for definition
{x}=fractional part of x=x-[x]
but x>=max{y: yeZ /\ y<=x}=[x]  so {x}=x-[x]>=0

[toc] | [prev] | [next] | [standalone]


#15402

FromNobody <nobody@nowhere.com>
Date2012-01-04 09:11 +0000
Message-ID<pan.2012.01.04.09.11.01.416000@nowhere.com>
In reply to#15383
On Tue, 03 Jan 2012 12:31:57 -0800, Michael Press wrote:

> By the C standard's implied definition the fractional
> part of x is less than or equal to zero for x <= 0.

I read it as treating a floating-point value as:

	sign * (integer_part + fractional_part)

where both integer_part and fractional_part are non-negative. Converting
to an integer discards fractional_part.

[toc] | [prev] | [next] | [standalone]


#15452

FromMichael Press <rubrum@pacbell.net>
Date2012-01-04 23:08 -0800
Message-ID<rubrum-F1F8B0.23080204012012@news.albasani.net>
In reply to#15402
In article <pan.2012.01.04.09.11.01.416000@nowhere.com>,
 Nobody <nobody@nowhere.com> wrote:

> On Tue, 03 Jan 2012 12:31:57 -0800, Michael Press wrote:
> 
> > By the C standard's implied definition the fractional
> > part of x is less than or equal to zero for x <= 0.
> 
> I read it as treating a floating-point value as:
> 
>         sign * (integer_part + fractional_part)
> 
> where both integer_part and fractional_part are non-negative. Converting
> to an integer discards fractional_part.

What is your point here? 
What definition of fractional part does your reading imply?

-- 
Michael Press

[toc] | [prev] | [next] | [standalone]


#15458

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2012-01-05 11:15 +0000
Message-ID<0.8f2bb956cd2606be95b2.20120105111551GMT.87ipkq5riw.fsf@bsb.me.uk>
In reply to#15452
Michael Press <rubrum@pacbell.net> writes:

> In article <pan.2012.01.04.09.11.01.416000@nowhere.com>,
>  Nobody <nobody@nowhere.com> wrote:
>
>> On Tue, 03 Jan 2012 12:31:57 -0800, Michael Press wrote:
>> 
>> > By the C standard's implied definition the fractional
>> > part of x is less than or equal to zero for x <= 0.
>> 
>> I read it as treating a floating-point value as:
>> 
>>         sign * (integer_part + fractional_part)
>> 
>> where both integer_part and fractional_part are non-negative. Converting
>> to an integer discards fractional_part.
>
> What is your point here? 
> What definition of fractional part does your reading imply?

While I like nothing better that good barney about definitions, lets not
lose sight of the fact that the C standard is not at all ambiguous about
the conversion that sparked this thread.  Talk of "readings" suggests
that there might be some doubt, but there isn't -- C's conversion from
floating to integer types "truncates towards zero".

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#15462

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-01-05 07:27 -0500
Message-ID<je44us$dq5$1@dont-email.me>
In reply to#15458
On 01/05/2012 06:15 AM, Ben Bacarisse wrote:
...
> While I like nothing better that good barney about definitions, lets not
> lose sight of the fact that the C standard is not at all ambiguous about
> the conversion that sparked this thread.  Talk of "readings" suggests
> that there might be some doubt, but there isn't -- C's conversion from
> floating to integer types "truncates towards zero".

Michael has absolute certainty (justified or not) about the mathematical
definition of "fractional part". Since the C standard provides no
definition of it's own, if there were a single definition of the term
that is universally used in the mathematical community, then that one is
the one that should apply. If his definition is the correct one, the
standard is self-contradictory: it specifies both that "the fractional
part is discarded" and that "the value is truncated toward zero".
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


#15466

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2012-01-05 13:03 +0000
Message-ID<0.e8a32b348d302cd073cd.20120105130358GMT.87r4ze47y9.fsf@bsb.me.uk>
In reply to#15462
James Kuyper <jameskuyper@verizon.net> writes:

> On 01/05/2012 06:15 AM, Ben Bacarisse wrote:
> ...
>> While I like nothing better that good barney about definitions, lets not
>> lose sight of the fact that the C standard is not at all ambiguous about
>> the conversion that sparked this thread.  Talk of "readings" suggests
>> that there might be some doubt, but there isn't -- C's conversion from
>> floating to integer types "truncates towards zero".
>
> Michael has absolute certainty (justified or not) about the mathematical
> definition of "fractional part". Since the C standard provides no
> definition of it's own, if there were a single definition of the term
> that is universally used in the mathematical community, then that one is
> the one that should apply. If his definition is the correct one, the
> standard is self-contradictory: it specifies both that "the fractional
> part is discarded" and that "the value is truncated toward zero".

I'd agree if the phrasing were "the fractional part is subtracted" but
"to discard" is not a natural verb to use with the mathematical
meaning[1] of fractional part.  Given the mathematical meaning, the C
standard would be saying that -3.2 is converted to an int by discarding
0.8.  What would that mean exactly?

Other parts of the standard help.  The decimal representation of
floating point values, for example, are described as having a fractional
part.

[1] I'm just using this as a shorthand.  I am not at all sure that there
is one universal mathematical meaning of "fractional part".
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#15478

FromMichael Press <rubrum@pacbell.net>
Date2012-01-05 16:28 -0800
Message-ID<rubrum-916339.16280105012012@news.albasani.net>
In reply to#15462
In article <je44us$dq5$1@dont-email.me>,
 James Kuyper <jameskuyper@verizon.net> wrote:

> On 01/05/2012 06:15 AM, Ben Bacarisse wrote:
> ...
> > While I like nothing better that good barney about definitions, lets not
> > lose sight of the fact that the C standard is not at all ambiguous about
> > the conversion that sparked this thread.  Talk of "readings" suggests
> > that there might be some doubt, but there isn't -- C's conversion from
> > floating to integer types "truncates towards zero".
> 
> Michael has absolute certainty (justified or not) about the mathematical
> definition of "fractional part". Since the C standard provides no
> definition of it's own, 

It as good as does. 

    the fractional part is discarded
    (i.e., the value is truncated toward zero)

> if there were a single definition of the term
> that is universally used in the mathematical community, then that one is
> the one that should apply. If his definition is the correct one, the
> standard is self-contradictory: it specifies both that "the fractional
> part is discarded" and that "the value is truncated toward zero".

You introduce correctness. For the record, I am not at all 
interested in correctness here. Good definitions are a 
result of much thought and work. 

Presumably truncating toward zero in the C standard 
is to reduce the number of cases where conversion leads to overflow.

-- 
Michael Press

[toc] | [prev] | [next] | [standalone]


#15486

FromJames Kuyper <jameskuyper@verizon.net>
Date2012-01-06 07:17 -0500
Message-ID<je6oom$tiu$1@dont-email.me>
In reply to#15478
On 01/05/2012 07:28 PM, Michael Press wrote:
> In article <je44us$dq5$1@dont-email.me>,
>  James Kuyper <jameskuyper@verizon.net> wrote:
> 
>> On 01/05/2012 06:15 AM, Ben Bacarisse wrote:
>> ...
>>> While I like nothing better that good barney about definitions, lets not
>>> lose sight of the fact that the C standard is not at all ambiguous about
>>> the conversion that sparked this thread.  Talk of "readings" suggests
>>> that there might be some doubt, but there isn't -- C's conversion from
>>> floating to integer types "truncates towards zero".
>>
>> Michael has absolute certainty (justified or not) about the mathematical
>> definition of "fractional part". Since the C standard provides no
>> definition of it's own, 
> 
> It as good as does. 
> 
>     the fractional part is discarded
>     (i.e., the value is truncated toward zero)

No, that's not in the Definitions section, nor are the words "fractional
part" italicized: those are the two methods used by the standard to
identify a definition. Therefore:

>> if there were a single definition of the term
>> that is universally used in the mathematical community, then that one is
>> the one that should apply. If his definition is the correct one, the
>> standard is self-contradictory: it specifies both that "the fractional
>> part is discarded" and that "the value is truncated toward zero".

If that were the case, then that paragraph would be a prime example of
why it's generically a bad idea for the standard to specify something
twice. In reality, your use of the definite article in your phrase "the
mathematical definition" seems to be unjustified - alternative
definitions are in use. One point of view looks at the value that would
print out as "-23.45", and parses it as having a sign factor of -1, an
integer part of 23, a decimal point, and a fractional part of 45/100.
Under that interpretation, "discarding the fractional part" means
converting "-12.34" into "-12.", and is indeed equivalent to truncation
toward zero. Therefore, this isn't a double specification; the
truncation clause clarifies which one of the multiple definitions
currently in use for "fractional part" is being used in the discard clause.

> You introduce correctness. For the record, I am not at all 
> interested in correctness here. Good definitions are a 
> result of much thought and work. 

The only thing being defined here is the behavior, not the meaning of
the terms used in that definition. You're right about good definitions,
but one of requirements for a good definition, one of the reasons it
requires careful thought, is that all of the terms used in that
definition should be used correctly.

> Presumably truncating toward zero in the C standard 
> is to reduce the number of cases where conversion leads to overflow.

I can't be sure what the reason was. Personally, I've never written code
where truncation of negative numbers toward zero was the desired
behavior. In most cases when I've converted a floating point number that
might be negative to an integer, what I wanted was lrint(x) (but
instead, I had to settle for (long)floor(x+0.5), because our contract
with our client requires use of C90 code); the second most common thing
I've wanted is (long)floor(x) - I can't remember ever wanting the result
that I would have gotten for negative values of x from (long)x.

The Rationale only says "There was strong agreement in the C89 Committee
that floating values should truncate toward zero
when converted to an integer type, the specification adopted in the
Standard. Although K&R 35 permitted negative floating values to truncate
away from zero, no C89 Committee member knew of an implementation that
functioned in such a manner.2"
Footnote 2 says "The Committee has since learned of one such
implementation."
-- 
James Kuyper

[toc] | [prev] | [next] | [standalone]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | comp.lang.c


csiph-web