zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Emanuel Berg <embe8573@student.uu.se>, zsh-workers@zsh.org
Subject: Re: why do ceil/floor give the decimal dot?
Date: Wed, 13 May 2015 19:56:17 -0700	[thread overview]
Message-ID: <150513195617.ZM29493@torch.brasslantern.com> (raw)
In-Reply-To: <87oalodmns.fsf@debian.uxu>

On May 14,  2:32am, Emanuel Berg wrote:
} Subject: why do ceil/floor give the decimal dot?
}
} >From #zsh (incal == yours truly):
} 
} <incal> why do ceil/floor give the decimal dot?
}         echo $(( floor(5) )) -> 5. Isn't that the
}         whole "point" that you want an integer? I know
}         I can get it with int but I thought I'd learn
}         if there is a reason
}         
} <danielsh> incal, I suspect that's an oversight.
} <danielsh> incal, it just uses the C floor() function,

It's not an oversight.  The doc says:

Most functions take floating point arguments and return a floating point
value.  However, any necessary conversions from or to integer type will
be performed automatically by the shell.  Apart from atan with a second
argument and the abs, int and float functions, all functions behave as
noted in the manual page for the corresponding C function [...]

So ciel and floor return float precisely and intentionally because the
C functions do so.


  reply	other threads:[~2015-05-14  2:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14  0:32 Emanuel Berg
2015-05-14  2:56 ` Bart Schaefer [this message]
2015-05-14  3:29   ` Emanuel Berg
2015-05-14  3:53     ` Lawrence Velázquez
2015-05-14  9:53       ` Peter Stephenson
2015-05-14 21:38         ` Emanuel Berg
2015-05-14 22:14           ` Lawrence Velázquez
2015-05-14 23:29             ` Emanuel Berg
2015-05-15  0:46             ` Oliver Kiddle
2015-05-15  1:07               ` Emanuel Berg
2015-05-15  1:27               ` Bart Schaefer
2015-05-18  8:16             ` Vincent Lefevre
2015-05-14  4:04     ` Bart Schaefer
2015-05-14  9:12       ` Emanuel Berg
2015-05-14 17:54         ` Bart Schaefer
2015-05-18  8:39           ` Vincent Lefevre
2015-05-18  9:41             ` Mikael Magnusson

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=150513195617.ZM29493@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=embe8573@student.uu.se \
    --cc=zsh-workers@zsh.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).