Help with rat()

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with rat()

Rik-4
Could someone run the following test under Matlab?

s = rat ([Inf 0 1 1/2])
size (s)

Thanks,
Rik


Reply | Threaded
Open this post in threaded view
|

Re: Help with rat()

Richard Crozier
R2018b:

 >> s = rat ([Inf 0 1 1/2])
size (s)

s =

   4×10 char array

     'Inf       '
     '0         '
     '1         '
     '1 + 1/(-2)'


ans =

      4.0000e+000    10.0000e+000



On 06/12/2018 16:46, Rik wrote:
> Could someone run the following test under Matlab?
>
> s = rat ([Inf 0 1 1/2])
> size (s)
>
> Thanks,
> Rik
>
>
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Reply | Threaded
Open this post in threaded view
|

Re: Help with rat()

Rik-4
On 12/06/2018 08:49 AM, CROZIER Richard wrote:

> R2018b:
>
>  >> s = rat ([Inf 0 1 1/2])
> size (s)
>
> s =
>
>    4×10 char array
>
>      'Inf       '
>      '0         '
>      '1         '
>      '1 + 1/(-2)'
>
>
> ans =
>
>       4.0000e+000    10.0000e+000
>
>
>
> On 06/12/2018 16:46, Rik wrote:
>> Could someone run the following test under Matlab?
>>
>> s = rat ([Inf 0 1 1/2])
>> size (s)
>>
>> Thanks,
>> Rik
>>
>>
Richard,

Could you try this as well?  I'm surprised that they don't return "1/0" for
Inf.

rats (Inf)

--Rik


Reply | Threaded
Open this post in threaded view
|

Re: Help with rat()

Richard Crozier


On 06/12/2018 17:05, Rik wrote:

> On 12/06/2018 08:49 AM, CROZIER Richard wrote:
>> R2018b:
>>
>>   >> s = rat ([Inf 0 1 1/2])
>> size (s)
>>
>> s =
>>
>>     4×10 char array
>>
>>       'Inf       '
>>       '0         '
>>       '1         '
>>       '1 + 1/(-2)'
>>
>>
>> ans =
>>
>>        4.0000e+000    10.0000e+000
>>
>>
>>
>> On 06/12/2018 16:46, Rik wrote:
>>> Could someone run the following test under Matlab?
>>>
>>> s = rat ([Inf 0 1 1/2])
>>> size (s)
>>>
>>> Thanks,
>>> Rik
>>>
>>>
> Richard,
>
> Could you try this as well?  I'm surprised that they don't return "1/0" for
> Inf.
>
> rats (Inf)
>
> --Rik
>

here you go (sorry I forgot to bottom post last time

 >> rats (Inf)

ans =

     '      1/0     '


Richard
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Reply | Threaded
Open this post in threaded view
|

Re: Help with rat()

Rik-4
On 12/06/2018 09:07 AM, CROZIER Richard wrote:

>
> On 06/12/2018 17:05, Rik wrote:
>> On 12/06/2018 08:49 AM, CROZIER Richard wrote:
>>> R2018b:
>>>
>>>   >> s = rat ([Inf 0 1 1/2])
>>> size (s)
>>>
>>> s =
>>>
>>>     4×10 char array
>>>
>>>       'Inf       '
>>>       '0         '
>>>       '1         '
>>>       '1 + 1/(-2)'
>>>
>>>
>>> ans =
>>>
>>>        4.0000e+000    10.0000e+000
>>>
>>>
>>>
>>> On 06/12/2018 16:46, Rik wrote:
>>>> Could someone run the following test under Matlab?
>>>>
>>>> s = rat ([Inf 0 1 1/2])
>>>> size (s)
>>>>
>>>> Thanks,
>>>> Rik
>>>>
>>>>
>> Richard,
>>
>> Could you try this as well?  I'm surprised that they don't return "1/0" for
>> Inf.
>>
>> rats (Inf)
>>
>> --Rik
>>
> here you go (sorry I forgot to bottom post last time
>
>  >> rats (Inf)
>
> ans =
>
>      '      1/0     '
>

Thanks.  This makes sense to me.  I am re-coding rat.m and I think I am
going to make it consistent with rats() and "format rat" so that it returns
"1/0" for Inf.

While checking this, I see that Octave returns "1/0" for "rats (-Inf)". 
Doesn't that seem odd?  Shouldn't it be "-1/0"?  If so, maybe I'll file a
bug report about that.

--Rik