archives of rust-dev@mozilla.org (2010-2015)
 help / color / mirror / Atom feed
From: Philippe Daouadi <blastrock0@free.fr>
To: Manish Goregaokar <manishsmail@gmail.com>,
	 Pim Schellart <p.schellart@gmail.com>
Cc: "rust-dev@mozilla.org" <rust-dev@mozilla.org>
Subject: Re: [rust-dev] About const
Date: Sun, 04 Jan 2015 17:57:53 +0100	[thread overview]
Message-ID: <54A97111.8060607@free.fr> (raw)
In-Reply-To: <CACpkpxnqZuFcU1-TjZDpMe_p+V8+HHtjNchKjUPeLQsHndammg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1612 bytes --]

If you want a generic pi, you should use the one in the Float trait

If you have
let x : f64 = ...;
x * Float::pi() will resolve to f64 pi

Philippe

On 01/04/2015 05:21 PM, Manish Goregaokar wrote:
> We have two types of floats, there is a Pi of both precision levels. I 
> don't think it's anything more than that. You should be able to cast 
> between the two, but that's it I guess. Rust tries to give explicit 
> control over such things.
>
> There is a Float trait (might have been renamed) if you want to use 
> generics.
>
> -Manish Goregaokar
>
> On Sun, Jan 4, 2015 at 3:07 PM, Pim Schellart <p.schellart@gmail.com 
> <mailto:p.schellart@gmail.com>> wrote:
>
>     Dear Rust Developers,
>
>     here is another ignorant question so feel free to ignore.
>     When reading the guide I came across "std::f64::consts::PI” for
>     pi. Now I was wondering why there are separate constants defined
>     for 32 and 64 bit floats and how this will work with generics. Do
>     you always have to define two functions to work on f32 and f64 or
>     is std::f64::consts::PI cast down to f32 in an equation with 32
>     bit variables? Is there also a general `typeless’ PI (or other
>     fundamental constants), as in Go for example?
>
>     Kind Regards,
>
>     Pim
>     _______________________________________________
>     Rust-dev mailing list
>     Rust-dev@mozilla.org <mailto:Rust-dev@mozilla.org>
>     https://mail.mozilla.org/listinfo/rust-dev
>
>
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev


[-- Attachment #2: Type: text/html, Size: 3292 bytes --]

  reply	other threads:[~2015-01-04 16:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-04  9:37 Pim Schellart
2015-01-04 16:21 ` Manish Goregaokar
2015-01-04 16:57   ` Philippe Daouadi [this message]
2015-01-04 17:08     ` Pim Schellart

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=54A97111.8060607@free.fr \
    --to=blastrock0@free.fr \
    --cc=manishsmail@gmail.com \
    --cc=p.schellart@gmail.com \
    --cc=rust-dev@mozilla.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox