Re: bug in IntegerPart ?

• To: mathgroup at smc.vnet.net
• Subject: [mg47850] Re: bug in IntegerPart ?
• From: ancow65 at yahoo.com (AC)
• Date: Wed, 28 Apr 2004 06:56:52 -0400 (EDT)
• References: <c6l8dj\$isr\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Bill Rowe <readnewsciv at earthlink.net> wrote in message news:<c6l8dj\$isr\$1 at smc.vnet.net>...
> On 4/26/04 at 2:41 AM, ancow65 at yahoo.com (AC) wrote:
>
> >"DrBob" <drbob at bigfoot.com> wrote in message
> >news:<c6g015\$4lk\$1 at smc.vnet.net>...
> >>There's NO reason to be puzzled. 1.65 and 1.3 can't be represented
> >>exactly in binary, so of course their difference may not be exact,
> >>either. Hence the division problems have different numerators.
> >
> >Your 'explanation' makes no sense whatsoever. Mathematica's binary
> >representations of 1.65-1.3 and 0.35 are the same. That can be seen
> >by comparing BaseForm[1.65 - 1.3, 2] with BaseForm[0.35,2]
>
> BaseForm isn't doing what you think and will not show the difference. BaseForm controls only the display of a number. By default Mathematica displays a number to 6 significant digits. Both 1.65 - 1.3 and .35 are the same to 6 significant digits. Consequently, these will display the same when using BaseForm.
>
> To see the difference use RealDigits or FullForm. Both of these clearly show the difference between 1.65 - 1.3 and .35.

The decimal numbers (1.65 - 1.3) and .35 are identical. The way
Mathematica performs subtraction makes them different.

>
> >(n = 2^^0.010110011001100110011 )
> > => 0.350000
>
> Right, here you've inputed a number accurate to 6 significant digits. So, Mathematica displays 6 significant digits

When I type 0.35, Mathematica assumes the machine precision.

Precision[0.35]
=> MachinePrecision

% // N
=> 15.9546

Isn't that natural to expect similar for binary numbers?

>
> > Notice the unussual display of trailing zeros.
>
> No, not unusual. Exactly as it should be. If I input 6 significant digits as
>
> .35`6, I expect Mathematica to display 6 significant digits with the default settings.

And, I guess, you don't see any problems with these three inputs
0.350000000000
N[0.350000000000, 6]
0.35`2
producing the same output 0.35.

>
> >Additionally, a completely legitimate expression
> >2^^BaseForm[0.35`, 2]
> >produces a syntax error message.
>
> The expression 2^^BaseForm[0.35, 2] isn't a legitimate expression. BaseForm puts a wrapper on the expression to control display. That is Head at BaseForm[0.35, 2] is BaseForm, not a sequence of binary digits.

BaseForm[0.35, 2] might be wrong as argument for 2^^#& but still it is
not a syntax error. Would you agree that the following expression
(which also generates a syntax error) is legitimate?

fun := 2^^# &

x=1;
2^^x

In better design 2^^BaseForm[0.35, 2] should return 0.35` or at
minimum unchanged expression.

AC

```

• Prev by Date: Re: FindRoot cannot find obvious solution
• Next by Date: Re: i don't understand mapping function over a long list
• Previous by thread: RE: Re: bug in IntegerPart ?
• Next by thread: Re: Re: bug in IntegerPart ?