help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is 0.01 here not 0.01 here 0.009999999999999?


From: Jean Louis
Subject: Re: What is 0.01 here not 0.01 here 0.009999999999999?
Date: Sat, 3 Apr 2021 08:36:10 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Arthur Miller <arthur.miller@live.com> [2021-04-03 07:41]:
> > Because it is database backed, minimum interaction with the
> > system is possible. In general, registered files are recorded in
> > the database on each kill or save of the buffer, or by single
> > key. I find it handy without any interactions.
> 
> Two different ways, each part on it's own, or as one macro. Much simpler
> than your decimal handling. I suggest to change your database scheme and
> store those as integers there too so you don't need to convert back and
> forth. Even better, skip the database and keep version number directly
> in your paper which you hopefully write in an org file ;-).

You know how version numbers may contain letters? That is why it is
string. Those which do appear as `numeric' type, I can easily "cast":

SELECT DISTINCT vc_revision::numeric FROM vc;
 vc_revision 
-------------
            
        1.23
           1
        1.19
        0.02

Then I could also use PostgreSQL mathematics to increase the `numeric'
cast:

SELECT DISTINCT trunc(vc_revision::numeric, 2) FROM vc WHERE vc_id = 6826;
 trunc 
-------
  0.50
(1 row)

rcdbusiness=# SELECT DISTINCT trunc(vc_revision::numeric + 0.01, 2) FROM vc 
WHERE vc_id = 6826;

 trunc 
-------
  0.51

Thus I could replace the function which I made in Emacs Lisp with
PostgreSQL combination.

These functions are insightful. I have to keep it a a note for
later. As they need to be decided by author. Maybe some intelligence
can be increased for computer to ask for a revision to be increased,
depending on the quantity of text changed.

> (defun rcd-vc-increase-major-number (version)
>   (aset version 0 (1+ (aref version 0))))
> 
> (defun rcd-vc-increase-minor-number (version)
>   (aset version 1 (1+ (aref version 1))))
> 
> (defun rcd-vc-increase-revision-number (version)
>        (aset version 2 (1+ (aref version 2))))
> 
> (defmacro incr-version (version-part version)
>   `(cond ((equal ,version-part 'major)
>          (aset ,version 0 (1+ (aref ,version 0))))
>         ((equal ,version-part 'minor)
>          (aset ,version 1 (1+ (aref ,version 1))))
>         ((equal ,version-part 'revision)
>          (aset ,version 2 (1+ (aref ,version 2))))))
> 
> (defun version-string (version)
>   (format "%s.%s.%s" (aref version 0) (aref version 1) (aref version 2)))
> 
> Eaxmple of usage:
> 
> (defvar my-version [0 0 0])
> 
> (rcd-vc-increase-revision-number my-version)
> (version-string my-version)
> 
> (incr-version 'major my-version)
> (incr-version 'minor my-version)
> (incr-version 'revision my-version)
> (version-string my-version)

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

Sign an open letter in support of Richard M. Stallman
https://rms-support-letter.github.io/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]