ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Hans Åberg" <haberg-1@telia.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: integer displayed as .0 float in Lua-5.3
Date: Sat, 11 Aug 2018 14:21:05 +0200	[thread overview]
Message-ID: <16DCE3A6-D419-4B0B-BF83-35F4A04C5ADB@telia.com> (raw)
In-Reply-To: <e3c76412-b897-f5da-47a1-e938cc2860b5@gmx.es>


> On 11 Aug 2018, at 11:33, Pablo Rodriguez <oinos@gmx.es> wrote:
> 
> On 08/09/2018 10:20 PM, Hans Åberg wrote:
>>> On 9 Aug 2018, at 21:20, Pablo Rodriguez wrote:
>>> [...]
>>> My background is in humanities and I don’t understand the exponent for
>>> being a float ("10²" contains an exponent
>>> [https://www.m-w.com/dictionary/exponent], but I would say is an integer
>>> in all possible worlds [or all the worlds I know ]).
>> 
>> It may refer to a floating point number syntax as in C++ [1], where the
>> three cases top there say that there must be a point '.' preceded or
>> followed by at least one digit, or at least one digit followed by an
>> exponent starting with 'e' or 'E'.
> 
> Many thanks for your explanation, Hans.

You are welcome.

> I thought there should be some kind of restriction when referring to the
> exponent, but this is why technical explanations aren’t always very
> clear. I mean, they have too many restrictions attached to them.

The C++ description allows for fast reading with just one lookahead character at a time, which is was important in C when it appeared in 1972 on the not so powerful computers of the day.

Then roundoff may make floating point numbers look like integers even they are not. For example, 1.0 could be 0.99999999 or 1.0000001.

So don't check floating numbers for equality, instead use say abs(x - y) < a for some small number a.

When adding exact integers and inexact floating point numbers, it is easiest to always make that inexact numbers, as exactness cannot always be guaranteed.


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2018-08-11 12:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 18:02 Pablo Rodriguez
2018-08-09 18:12 ` Wolfgang Schuster
2018-08-09 19:20   ` Pablo Rodriguez
2018-08-09 19:34     ` Alan Braslau
2018-08-09 20:00       ` Pablo Rodriguez
2018-08-09 20:16         ` Alan Braslau
2018-08-11  9:29           ` Pablo Rodriguez
2018-08-11 17:55             ` Alan Braslau
2018-08-12 14:44             ` Arthur Reutenauer
2018-08-09 20:25         ` Hans Hagen
2018-08-11 10:05           ` Pablo Rodriguez
2018-08-09 20:20     ` Hans Åberg
2018-08-11  9:33       ` Pablo Rodriguez
2018-08-11 12:21         ` Hans Åberg [this message]
2018-08-12  7:49         ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16DCE3A6-D419-4B0B-BF83-35F4A04C5ADB@telia.com \
    --to=haberg-1@telia.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).