Re: Strange problem
Joel Crook wrote:
>>
> return objects [obj] [floor (att)] [1+((att - floor (att)) * 10)] -->ERROR
>
>{
> {1,0,{},{ 0, 0},{639,479}, 1,1,1},
> {1,0,{},{10,10},{459,459},-1,1,1}
> ^
> } |
>I changed the line to read:
> return objects [obj] [floor (att)] [1+((att - floor (att)) * 1)] -->ERROR
>
>I get the result {10,10}
>
>att-floor(att) is .1 which you are trying to turn into a 1 by multiplying
>by 10 but I suspect that Euphoria is expecting is an integer -- sure enough
>In the manual I found:
>
>"Non-integer subscripts are rounded down to an integer" so Euphoria is
>seeing that last element number as [0] and not [1]
Okay, just for fun, let us assume that it works the way you say. There is
one caveat. The reason why 10 times .1 does not give us back 1 is that
the float that is created from 4.1 is slightly less than 4.1, and therefore the
equation gives us back a number that is slightly less than 1...then by the
manual, it is rounded down to 0. The rounding may not be dependable at
4.2 or 4.3 or ... The error is in the conversion from base 10 decimal to
binary floating point. I have not confirmed this, but until I actually tested
it,
I would not trust your adding of 1 to the result. Sometimes the conversion
might give a number just slightly larger than the decimal and then the
result will be 1 too large. I would love for someone to tell me that it always
converts to the largest float smaller than the original number. I did not find
that assurance in the manual. RDS...time to tell us how you do it.
Everett L.(Rett) Williams
rett at gvtc.com
|
Not Categorized, Please Help
|
|