Loading ...
Sorry, an error occurred while loading the content.

Re: Patch to try out: floating point

Expand Messages
  • Antony Scriven
    ... How many people actually do that? Should they be doing that? IMHO I d force people to use whitespace for concatenation in this case (i.e. 123 . 456) and
    Message 1 of 65 , Apr 8, 2008
    • 0 Attachment
      On 08/04/2008, Bram Moolenaar <Bram@...> wrote:

      > I have been preparing a talk for the upcoming FISL
      > conference in Brazil:
      > http://fisl.softwarelivre.org/9.0/www/
      >
      > One of the items I planned to discuss is why Vim has no
      > floating point support. Well, this turned into actually
      > implementing it.
      >
      > The main problem with floating point is that the usual
      > notation already has a meaning:
      >
      > echo 123.456
      > 123456
      >
      > [...]

      How many people actually do that? Should they be doing that?
      IMHO I'd force people to use whitespace for concatenation in
      this case (i.e. 123 . 456) and have 123.456 be a floating
      point number. That's how Perl works, for example. --Antony

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Ben Schmidt
      ... +1. Ben. ... --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_dev maillist. For more information, visit
      Message 65 of 65 , Apr 16, 2008
      • 0 Attachment
        Tony Mechelynck wrote:
        > On 09/04/08 17:30, Bram Moolenaar wrote:
        >> Tony Mechelynck wrote:
        > [...]
        >>> Oh, oh.. it had started working (and&1.0e256 multiplied by itself gives
        >>> inf, which is correct), but ":echo&1.0e308" crashes gvim (on Linux
        >>> i686) with SIGSEGV.
        >> Easy to reproduce. Turns out that this line causes it:
        >>
        >> sprintf(tmp, format, f);
        >>
        >> Here "format" is "%f" and "f" is your value 1e+308. The result is an
        >> awful long string of numbers. I suppose it's about 308 digits. How big
        >> does "tmp" need to be to hold any result here? I don't think %f has a
        >> way of specifying a maximal field width.
        > [...]
        >
        > I suggest a third floating-point format (%g maybe, or something else if
        > that is already taken) which would mean "either %f or %e depending on
        > the size of the exponent" similar, IIRC, to the number output formats
        > available in FORTRAN and/or BASIC. That format would be implicit when
        > ":echo"ing a floating-point number. (Yes, I know, Vim is neither FORTRAN
        > nor BASIC, but I feel this kind of thing would be better than crashing
        > or even than giving an error.)

        +1.

        Ben.

        > IIRC, in FORTRAN, the G output format would give (for different values
        > output under a single format) results like:
        >
        > -1.234567E-123 (for a small number)
        > 2.25 (with spaces to the same width)
        > 342.5682 (with spaces for a large number but not too large)
        > 6.020000E+023 (for an even bigger number)
        > NAN (a special case)
        > -INF (another special case)
        >
        > (this from what [I think that] I remember from the time I used FORTRAN
        > on computers whose printers had no lowercase letters).





        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      Your message has been successfully submitted and would be delivered to recipients shortly.