Gnus development mailing list
 help / color / mirror / Atom feed
* Gnus/5.1299999999999999
@ 2012-03-05  8:59 Katsumi Yamaoka
  2012-03-10  0:33 ` Gnus/5.1299999999999999 Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Katsumi Yamaoka @ 2012-03-05  8:59 UTC (permalink / raw)
  To: ding

Hi,

Please see the User-Agent header of this article.  This seems due
to some math library of Cygwin that I recently updated into:

$ uname -a
CYGWIN_NT-5.1 localhost 1.7.11(0.260/5/3) 2012-02-24 14:05 i686 Cygwin

No difference is in Gnus v5.13 nor Emacs 23.3.  Only XEmacs is
sane.  What I can observe in Emacs's *scratch* buffer are:

5.13
 => 5.1299999999999999
(format "%s" 5.13)
 => "5.1299999999999999"

(format "%1.2f" 5.13)
 => "5.13"

This looks good at first, however it is spoiled by `string-to-number'
that `gnus-continuum-version' uses:

(string-to-number (format "%1.2f" 5.13))
 => 5.1299999999999999

Through some trial-and-errors, I concluded that there is no way
to express the floating number 5.130004 in this platform.  So,
I'm going to use this one hereafter:

(if (featurep 'emacs)
    (setq gnus-user-agent
	  (format "Gnus/5.13%04d %s Emacs/%s (%s)"
		  (round (* 10 (string-to-number gnus-version-number)))
		  gnus-version
		  (mapconcat 'identity
			     (nbutlast (split-string emacs-version "\\."))
			     ".")
		  system-configuration)))

Of course, what should be fixed is Cygwin, I believe.  Sigh.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Gnus/5.1299999999999999
  2012-03-05  8:59 Gnus/5.1299999999999999 Katsumi Yamaoka
@ 2012-03-10  0:33 ` Lars Magne Ingebrigtsen
  2013-07-23  5:22   ` Gnus/5.1299999999999999 Katsumi Yamaoka
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-03-10  0:33 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> No difference is in Gnus v5.13 nor Emacs 23.3.  Only XEmacs is
> sane.  What I can observe in Emacs's *scratch* buffer are:
>
> 5.13
>  => 5.1299999999999999

Well, that's probably as "correct" as 5.13.  Representing floating point
numbers is tricky.

> (if (featurep 'emacs)
>     (setq gnus-user-agent
> 	  (format "Gnus/5.13%04d %s Emacs/%s (%s)"
> 		  (round (* 10 (string-to-number gnus-version-number)))
> 		  gnus-version
> 		  (mapconcat 'identity
> 			     (nbutlast (split-string emacs-version "\\."))
> 			     ".")
> 		  system-configuration)))

Could `gnus-extended-version' be fixed somehow?  By using, for instance,
%10.8f instead of %s, and then trimming back trailing zeroes?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Gnus/5.1299999999999999
  2012-03-10  0:33 ` Gnus/5.1299999999999999 Lars Magne Ingebrigtsen
@ 2013-07-23  5:22   ` Katsumi Yamaoka
  2013-07-23  6:09     ` Gnus/5.1299999999999999 Katsumi Yamaoka
  0 siblings, 1 reply; 4+ messages in thread
From: Katsumi Yamaoka @ 2013-07-23  5:22 UTC (permalink / raw)
  To: ding

cf. http://thread.gmane.org/gmane.emacs.gnus.general/81516

Lars Magne Ingebrigtsen wrote:
> Katsumi Yamaoka <yamaoka@jpl.org> writes:
>> No difference is in Gnus v5.13 nor Emacs 23.3.  Only XEmacs is
>> sane.  What I can observe in Emacs's *scratch* buffer are:
>>
>> 5.13
>>  => 5.1299999999999999

> Well, that's probably as "correct" as 5.13.  Representing floating point
> numbers is tricky.

Yes, that's correct, as for "Gnus v5.13".  However, as for "Ma Gnus",
it is 5.1299999999999999 on Cygwin no matter what the version number
is:

(gnus-continuum-version "Ma Gnus v0.1")
 => 5.1299999999999999
(gnus-continuum-version "Ma Gnus v0.99")
 => 5.1299999999999999

So, it not only makes the User-Agent header ugly, but also disables
`gnus-update-format-specifications' from comparing the newsrc file
versions.

> Could `gnus-extended-version' be fixed somehow?  By using, for instance,
> %10.8f instead of %s, and then trimming back trailing zeroes?

Unfortunately, no.
Because the value is broken by `gnus-continuum-version' before
it is passed to `gnus-extended-version'.  How it breaks it is as
follows:

(defun gnus-continuum-version (&optional version)
  "Return VERSION as a floating point number."
[...]
;; Where `alpha' is "Ma", `minor' is 8, and `least' is 0.
  (string-to-number
   (format "%s00%02d%02d"
           (+ 5 (* 0.02
                   (abs
                    (- (mm-char-int (aref (downcase alpha) 0)) ;; 109
                       (mm-char-int ?t) ;; 116
                       )                ;; -7
                    )                   ;; 7
                   )                    ;; 0.14000000000000001
              -0.01)                    ;; 5.1299999999999999
           minor least)                 ;; "5.1299999999999999000800"
   )                                    ;; 5.1299999999999999

Now I've committed a new idea.  The main point of this change is
to make it do the main calculations in integers.  This will work
on any platform, from "(ding) Gnus" through "A* Gnus".

(gnus-continuum-version "Ma Gnus v0.8")
 => 5.1300080000000001
(gnus-continuum-version "Gnus v5.13")
 => 5.1299999999999999
(gnus-continuum-version "A* Gnus v0.1")
 => 5.3700010000000002

(gnus-extended-version)
 => "Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (cygwin)"
(let ((gnus-version "Gnus v5.13"))
  (gnus-extended-version))
 => "Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (cygwin)"
(let ((gnus-version "A* Gnus v0.1"))
  (gnus-extended-version))
 => "Gnus/5.370001 (A* Gnus v0.1) Emacs/24.3.50 (cygwin)"



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Gnus/5.1299999999999999
  2013-07-23  5:22   ` Gnus/5.1299999999999999 Katsumi Yamaoka
@ 2013-07-23  6:09     ` Katsumi Yamaoka
  0 siblings, 0 replies; 4+ messages in thread
From: Katsumi Yamaoka @ 2013-07-23  6:09 UTC (permalink / raw)
  To: ding

Katsumi Yamaoka wrote:
> Lars Magne Ingebrigtsen wrote:
[...]
>> Could `gnus-extended-version' be fixed somehow?  By using, for instance,
>> %10.8f instead of %s, and then trimming back trailing zeroes?

> Unfortunately, no.

Oops, I realized that that way will do.  It only requires smaller
change than what I did, so I'm going to revert the last change
and do it.

(format "%1.2f" 5.1299999999999999)
 => "5.13"
(gnus-replace-in-string (format "%1.8f" 5.1300080000000001) "0+\\'" "")
 => "5.130008"



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-23  6:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-05  8:59 Gnus/5.1299999999999999 Katsumi Yamaoka
2012-03-10  0:33 ` Gnus/5.1299999999999999 Lars Magne Ingebrigtsen
2013-07-23  5:22   ` Gnus/5.1299999999999999 Katsumi Yamaoka
2013-07-23  6:09     ` Gnus/5.1299999999999999 Katsumi Yamaoka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).