[Scilab-users] How to print int64 or uint64 integers at full accuracy?

Samuel Gougeon sgougeon at free.fr
Mon Aug 29 10:32:02 CEST 2016


Le 29/08/2016 09:46, Jan Åge Langeland a écrit :
> On 29.08.2016 02:09, Tim Wescott wrote:
>> A kludge would be to make it into two integers.
>
> Each case may not be so complex to work around, but in total it seems 
> like Scilab 6 is not yet well prepared for int64 and uint64.
>
> For instance  %x and %o need to be handled too, functions like 
> dec2bin() and dec2hex() should work - etc.
>
> Generally a lot of caution is needed when using these 64 bit 
> integers.  Example:
> --> int64(2^62+256+1) //loss of prescision
>   ans  =
>    4611686018427387904
Yes, but this loss is expected, since 2^62+256+1 is performed with 
decimal encoding.
It is a case similar to the classical 1+ %eps/2
It is not a bug.
For dec2*(): int64 encoding is already supported, and a clear error 
message is yielded for input integers > 2^52

--> dec2bin(int64(2^52))
  ans  =
  10000000000000000000000000000000000000000000000000000

--> dec2bin(int64(2^53))
at line    12 of function dec2bin ( 
SCI\modules\elementary_functions\macros\dec2bin.sci line 43 )
dec2base: Wrong value for input argument #1: Must be between 0 and 2^52.

So, there is still a limitation, but it is clearly stated. At least, 
integers from 2^33 to 2^52 are newly supported :)

Samuel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160829/a3ffc54b/attachment.htm>


More information about the users mailing list