On Thu, Jan 21, 2016 at 1:48 PM, Ken Takata <[email protected]> wrote:
> Hi mattn and all,
>
> I think that supporting 64-bit Number (even on 32-bit systems) is very useful.
> One of the best examples is getfsize() as mattn said. 32-bit Number is too
> small to represent a filesize nowadays.
>
>
> 2014/1/6 Mon 15:34:44 UTC+9 mattn wrote:
>> https://gist.github.com/mattn/8278843
>>
>> This is in progress.
>
> I have updated mattn's patch:
> https://bitbucket.org/k_takata/vim-ktakata-mq/src/fd966d51f56b69e02d9ebb984355f692b73b2260/num64.patch?at=default&fileviewer=file-view-default
>
> Changes are:
>
> * Sync with the latest codebase.
> * VC9 or earlier doesn't have stdint.h, int64_t and uint64_t.
> Use __int64 for old Windows compilers.
> * Define FEAT_NUM64 in feature.h.
> (If someone doesn't like this feature, s/he can disable this by editing
> feature.h.)
> * Display +/-num64 in :version.
> * Add has('num64').
> * Adjust the behaviour when dividing by 0. (:help expr-/)
> * Adjust the behaviour of float2nr().
>
> I confirmed that getfsize() returned a right value even if the filesize was
> over 2 GiB. (My largefile patches are also needed.)
> I also confirmed that all existing tests passed.
>
> Of cause, more tests are needed, and documents should be updated.
>
> (See also: [patch] Always use long for vimscript Numbers
> https://groups.google.com/d/topic/vim_dev/Ju0DDCqeuMc/discussion )
>
>
> Regards,
> Ken Takata
>
Vim differs from some editors such as sed in that it loads the whole
editfile in memory. In a 64-bit Vim, a Number is a 64-bit integer so
no change is required. In a 32-bit Vim, if the filesize doesn't fit in
a 32-bit integer, or even in 'maxmem' (which cannot be more than half
the available system memory), we know that the file won't fit in
memory: we won't be able to edit it. If we need better precision,
which IMHO won't be often, we can get it by parsing a directory
listing (on Unix: let str = system('ls -l ' . expand('filename.ext',
':p')) or similar).
For other purposes, we can exceed 32-bit integer precision in 32-bit
code by using the FPU ("pretending" that our integers are
floating-point numbers). In that case, of course we have to know how
many bits of mantissa are available before we start losing lower-end
digits (lower-end binary digits, for the purists among you).
IIUC, Vim's Float format uses what C calls "double" which on Intel
i686 processors means a 64-bit data item including 53 significant
bits. The "long double" format (maximum hardware precision, with 64
bits _plus_ exponent) is not used by Vim to store data (though the
floating-point hardware uses it for computations, even in Vim). This
"double" format is better than 32-bit but does not reach 64-bit
integers.
Best regards,
Tony.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.