[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mod and using large numbers has strange effects:
From: |
Gordon Haverland |
Subject: |
Re: mod and using large numbers has strange effects: |
Date: |
Thu, 12 Oct 2017 15:38:15 -0700 |
On Thu, 12 Oct 2017 17:58:59 -0400
RT <address@hidden> wrote:
> >> realmax
> ans = 1.79769313486232e+308
>
>
> for ii=
> 0:360
> z=mod(realmax,ii)
> end
>
> z varies from
> z = Inf
> z = 0
> z = 0
> z = 1.99584030953472e+292
>
> I was expecting z to be between 0 and 360 what am I doing wrong.
Expecting a reasonable answer.
You have a number, which you may be expecting to be a counting number
(integer) which has 308 decimal places. If we convert that to base 2,
it will be some huge number of bits. Octave might be using 8 bytes to
represent a number. Nowhere near the size you need.
Work with much smaller numbers, and slowly increase them. Look at how
the error scales with the size of the number.
Gord