Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-09-08 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
--+
 Reporter:  teor  |  Owner:  catalyst
 Type:  enhancement   | Status:  closed
 Priority:  Medium|  Milestone:  Tor:
  |  0.3.2.x-final
Component:  Core Tor/Tor  |Version:
 Severity:  Normal| Resolution:
  |  implemented
 Keywords:  doc, tor-safety, review-group-23  |  Actual Points:
Parent ID:| Points:  0.5
 Reviewer:|Sponsor:
--+
Changes (by nickm):

 * status:  needs_review => closed
 * resolution:   => implemented


Comment:

 Looks like a good, comprehensive start to me.  I've merged it to master.
 We can add more here as we go along.  Thanks!

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-09-08 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
--+
 Reporter:  teor  |  Owner:  catalyst
 Type:  enhancement   | Status:
  |  needs_review
 Priority:  Medium|  Milestone:  Tor:
  |  0.3.2.x-final
Component:  Core Tor/Tor  |Version:
 Severity:  Normal| Resolution:
 Keywords:  doc, tor-safety, review-group-23  |  Actual Points:
Parent ID:| Points:  0.5
 Reviewer:|Sponsor:
--+
Changes (by catalyst):

 * status:  needs_revision => needs_review


Comment:

 Pushed an update to oniongit that incorporates these suggestions.

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-09-08 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
--+
 Reporter:  teor  |  Owner:  catalyst
 Type:  enhancement   | Status:
  |  needs_revision
 Priority:  Medium|  Milestone:  Tor:
  |  0.3.2.x-final
Component:  Core Tor/Tor  |Version:
 Severity:  Normal| Resolution:
 Keywords:  doc, tor-safety, review-group-23  |  Actual Points:
Parent ID:| Points:  0.5
 Reviewer:|Sponsor:
--+

Comment (by catalyst):

 These are all good suggestions!  I'm trying to figure out how to include
 them without making the section too long.

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-09-07 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
--+
 Reporter:  teor  |  Owner:  catalyst
 Type:  enhancement   | Status:
  |  needs_revision
 Priority:  Medium|  Milestone:  Tor:
  |  0.3.2.x-final
Component:  Core Tor/Tor  |Version:
 Severity:  Normal| Resolution:
 Keywords:  doc, tor-safety, review-group-23  |  Actual Points:
Parent ID:| Points:  0.5
 Reviewer:|Sponsor:
--+
Changes (by teor):

 * status:  needs_review => needs_revision


Comment:

 Replying to [comment:9 catalyst]:
 > Proposed patch in https://oniongit.eu/catalyst/tor/merge_requests/1

 Looks great!

 T1. It might help to be more specific here:
 {{{
- If you must send floating point numbers on the wire, serialize
  them in a platform-independent way. Tor avoids exchanging
  floating-point values. But when it does, it uses ASCII numerals,
  with a decimal point ("."). This is the "C" Locale Format.
 }}}

 For reference, I could only find one floating-point value in all the
 directory documents.
 In extra-info documents, Tor uses the following C code:
 {{{
 printf("epsilon=%.2f", EPSILON_CONSTANT)
 }}}

 Which produces:
 {{{
 epsilon=0.30
 }}}

 T2. I'd also like to add some more notes like this:
 {{{
- Changing the order of operations changes the results of many
  floating-point calculations. Be careful when you simplify
  calculations! If the order is significant, document it using
  a code comment.
- Comparing most floating point values for equality is unreliable.
  Avoid using `==`, instead, use `>=` or `<=`.
- Testing floating-point outputs in unit tests is hard. Tests
  that work on your machine can fail in other environments.
 }}}

 Once you've made these changes, feel free to flip this to "ready to
 merge".

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-09-07 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
--+
 Reporter:  teor  |  Owner:  catalyst
 Type:  enhancement   | Status:
  |  needs_review
 Priority:  Medium|  Milestone:  Tor:
  |  0.3.2.x-final
Component:  Core Tor/Tor  |Version:
 Severity:  Normal| Resolution:
 Keywords:  doc, tor-safety, review-group-23  |  Actual Points:
Parent ID:| Points:  0.5
 Reviewer:|Sponsor:
--+
Changes (by catalyst):

 * status:  accepted => needs_review


Comment:

 Proposed patch in https://oniongit.eu/catalyst/tor/merge_requests/1

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-09-07 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
--+
 Reporter:  teor  |  Owner:  catalyst
 Type:  enhancement   | Status:  accepted
 Priority:  Medium|  Milestone:  Tor:
  |  0.3.2.x-final
Component:  Core Tor/Tor  |Version:
 Severity:  Normal| Resolution:
 Keywords:  doc, tor-safety, review-group-23  |  Actual Points:
Parent ID:| Points:  0.5
 Reviewer:|Sponsor:
--+
Changes (by catalyst):

 * owner:  (none) => catalyst
 * status:  needs_review => accepted


Comment:

 There's no patch here so I'll work on one.

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-09-05 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
-+
 Reporter:  teor |  Owner:  (none)
 Type:  enhancement  | Status:  needs_review
 Priority:  Medium   |  Milestone:  Tor: 0.3.2.x-final
Component:  Core Tor/Tor |Version:
 Severity:  Normal   | Resolution:
 Keywords:  doc, tor-safety  |  Actual Points:
Parent ID:   | Points:  0.5
 Reviewer:   |Sponsor:
-+

Comment (by catalyst):

 Here are a few useful references:

 * [http://floating-point-gui.de/ What Every Programmer Should Know About
 Floating-Point Arithmetic]
 * [https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html What
 Every Computer Scientist Should Know About Floating-Point Arithmetic]
 * [http://www.auburn.edu/~tamtiny/lecture%207.pdf Lecture 7 Floating point
 arithmetic and stability]

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-09-01 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
-+
 Reporter:  teor |  Owner:  (none)
 Type:  enhancement  | Status:  needs_review
 Priority:  Medium   |  Milestone:  Tor: 0.3.2.x-final
Component:  Core Tor/Tor |Version:
 Severity:  Normal   | Resolution:
 Keywords:  doc, tor-safety  |  Actual Points:
Parent ID:   | Points:  0.5
 Reviewer:   |Sponsor:
-+
Changes (by mcs):

 * cc: mcs (added)


--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-08-31 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
-+
 Reporter:  teor |  Owner:  (none)
 Type:  enhancement  | Status:  needs_review
 Priority:  Medium   |  Milestone:  Tor: 0.3.2.x-final
Component:  Core Tor/Tor |Version:
 Severity:  Normal   | Resolution:
 Keywords:  doc, tor-safety  |  Actual Points:
Parent ID:   | Points:  0.5
 Reviewer:   |Sponsor:
-+
Changes (by catalyst):

 * cc: catalyst (added)


--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-08-31 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
-+
 Reporter:  teor |  Owner:  (none)
 Type:  enhancement  | Status:  needs_review
 Priority:  Medium   |  Milestone:  Tor: 0.3.2.x-final
Component:  Core Tor/Tor |Version:
 Severity:  Normal   | Resolution:
 Keywords:  doc, tor-safety  |  Actual Points:
Parent ID:   | Points:  0.5
 Reviewer:   |Sponsor:
-+

Comment (by yawning):

 Replying to [comment:2 teor]:
 > 4. Try to do as many of your calculations in integer precision as
 possible, and convert to floating point for display or transfer.

 "No non-serialized floating point values on the wire."

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-08-31 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
-+
 Reporter:  teor |  Owner:  (none)
 Type:  enhancement  | Status:  needs_review
 Priority:  Medium   |  Milestone:  Tor: 0.3.2.x-final
Component:  Core Tor/Tor |Version:
 Severity:  Normal   | Resolution:
 Keywords:  doc, tor-safety  |  Actual Points:
Parent ID:   | Points:  0.5
 Reviewer:   |Sponsor:
-+

Comment (by teor):

 4. Try to do as many of your calculations in integer precision as
 possible, and convert to floating point for display or transfer.

 It might also help to link to a general list of do's and don't's, like:
 * don't compare floating-point numbers using equals (comparing with 0.0 is
 an exception)
 * always check for division by zero, even if the inputs to a function are
 non-zero, the result can round to zero

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

Re: [tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-08-30 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
-+
 Reporter:  teor |  Owner:  (none)
 Type:  enhancement  | Status:  needs_review
 Priority:  Medium   |  Milestone:  Tor: 0.3.2.x-final
Component:  Core Tor/Tor |Version:
 Severity:  Normal   | Resolution:
 Keywords:  doc, tor-safety  |  Actual Points:
Parent ID:   | Points:  0.5
 Reviewer:   |Sponsor:
-+
Changes (by teor):

 * status:  new => needs_review


--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs

[tor-bugs] #23368 [Core Tor/Tor]: Add design and coding guidelines for using floating point

2017-08-30 Thread Tor Bug Tracker & Wiki
#23368: Add design and coding guidelines for using floating point
--+
 Reporter:  teor  |  Owner:  (none)
 Type:  enhancement   | Status:  new
 Priority:  Medium|  Milestone:  Tor: 0.3.2.x-final
Component:  Core Tor/Tor  |Version:
 Severity:  Normal|   Keywords:  doc, tor-safety
Actual Points:|  Parent ID:
   Points:  0.5   |   Reviewer:
  Sponsor:|
--+
 We should add these to a document in doc/HACKING:

 1. Don't use floats.
 2. If you must use floats, document how the limits of floating point
 precision and calculation accuracy affect function outputs.
 3. Remember that different environments can get different results from the
 same floating point calculations. So you can't use floats in anything that
 needs to be deterministic, like consensus generation.

--
Ticket URL: 
Tor Bug Tracker & Wiki 
The Tor Project: anonymity online
___
tor-bugs mailing list
tor-bugs@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs