It is currently Thu Mar 30, 2017 3:36 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ROUND p.57 v1.90.01
Unread postPosted: Mon Mar 13, 2017 11:45 am 
Offline

Joined: Sat Feb 11, 2017 1:40 am
Posts: 62
Quote:
The <mode_sexp> is an optional rounding mode. It is a one-or two-character mnemonic code that tells ROUND() what kind of rounding to do.

1. What is the default? It is explained later, too later as for me. You should say here something like "see below".


Quote:
There are seven rounding modes:

"HE" Half-even -4.0 -4.0 -3.0 3.0 4.0 4.0
"HU" Half-up -4.0 -4.0 -3.0 3.0 4.0 4.0


2. Two ones actually do exactly the same, if I believe the table. Does not HE act differently of HU in some case?


Top
 Profile  
 
 Post subject: Re: ROUND p.57 v1.90.01
Unread postPosted: Tue Mar 21, 2017 4:30 am 
Offline

Joined: Wed Oct 03, 2012 9:53 am
Posts: 2786
Location: Colorado, U.S.
  1. There is no default rounding mode. The default behavior is different from all of the rounding modes. Perhaps I can make that clearer by putting "no mode" or "legacy mode" as a line in the table. My problem is that the modes are defined by Java, and the legacy mode is not defined by Java. The BASIC! programmer should not know or care what comes from Java.
  2. The table does not cover all possible cases. There isn't enough room. But there are enough cases that you know what would happen in all other cases.
    For example:
    • You can see that HE rounds -3.5 to -4, not -3. You can understand that it does that because -4 is even, and -3 is odd. Therefore HE would round -2.5 to -2.
    • However, HU rounds -3.5 to -4 because -4 is "up" (farther from 0) and -3 is "down" (closer to 0). By that understanding, you know that HU would round -2.5 to -3.
    While I am adding a row to the table, maybe I can see about squeezing in a column or two.

- Marc


Top
 Profile  
 
 Post subject: Re: ROUND p.57 v1.90.01
Unread postPosted: Tue Mar 21, 2017 5:05 am 
Offline

Joined: Sat Feb 11, 2017 1:40 am
Posts: 62
What do you think, Marc, of writing the following text?
The <mode_sexp> is an optional rounding mode. It is a one-or two-character mnemonic code that tells ROUND() what kind of rounding to do.
There is no default rounding mode, the default behavior (see it below) is different from all of the rounding modes. 


Top
 Profile  
 
 Post subject: Re: ROUND p.57 v1.90.01
Unread postPosted: Thu Mar 23, 2017 5:29 pm 
Offline

Joined: Wed Oct 03, 2012 9:53 am
Posts: 2786
Location: Colorado, U.S.
Thanks for the suggestion. I will use something like that in the new text, but it will change a little with the changes in the table.

I'm adding a row at the top. Under "Mode:" it says "(none)", and under "Meaning:" it says "Legacy", which will be explained in the text.
There is room to add two more columns, so right in the middle I'm adding "-2.5" and "2.5".
The new example columns show the difference between "HE" and "HU", and probably some other things.

I'll change the text to say there are "seven named modes and one unnamed Legacy mode, explained below", or something like that.

Finally, while working on that I discovered that the text describing Legacy mode is wrong. It said, "adds +0.5 and rounds down (toward zero)". That's not true. It adds +0.5 and rounds toward -∞ (floor function).

A note on BASIC! internals: the Legacy mode was not some whim of Paul's. It uses the standard Java rounding function for floating point numbers. The named modes, which are much newer, are defined by Java's BigDecimal class.

- Marc (somehow getting way behind in the forum again!)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred