POV-Ray : Newsgroups : povray.off-topic : Why is 1e0 a float? Server Time
5 Nov 2024 03:15:04 EST (-0500)
  Why is 1e0 a float? (Message 1 to 4 of 4)  
From: Shay
Subject: Why is 1e0 a float?
Date: 30 Oct 2007 23:13:46
Message: <472800fa$1@news.povray.org>
I noticed this while browsing through some stuff I'd cut and pasted into 
my .vimrc.

syn match Float "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
" floating point number, without dot, with exponent
" Author:	Jean-Marc Vanel <http://jmvanel.free.fr/>

Though this might be some kind of C thing, but tried it in Python:
 >>> 1+0
1
 >>> 2-1
1
 >>> 1*1
1
 >>> 1/1
1
 >>> 3%2
1
 >>> 1e0
1.0
 >>> pow(1,1)
1
 >>>

That last one especially throws me. Why is 1e0 a float? Simply to cover 
instances where NeN represents a float value with no decimal points 
anywhere in the expression? Is the language's interpretation that 
"dumb"? If that's the case, why doesn't pow always return a float?

Just curious.
  -Shay


Post a reply to this message

From: Darren New
Subject: Re: Why is 1e0 a float?
Date: 30 Oct 2007 23:35:34
Message: <47280616@news.povray.org>
Shay wrote:
> That last one especially throws me. Why is 1e0 a float?

Because it's defined that way?

> If that's the case, why doesn't pow always return a float?

Because it's defined that way?

-- 
   Darren New / San Diego, CA, USA (PST)
     Remember the good old days, when we
     used to complain about cryptography
     being export-restricted?


Post a reply to this message

From: Tim Cook
Subject: Re: Why is 1e0 a float?
Date: 31 Oct 2007 00:09:18
Message: <47280dfe$1@news.povray.org>
Shay wrote:
> I noticed this while browsing through some stuff I'd cut and pasted into 
> my .vimrc.
> 
> syn match Float "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
> " floating point number, without dot, with exponent
> " Author:    Jean-Marc Vanel <http://jmvanel.free.fr/>
> 
> Though this might be some kind of C thing, but tried it in Python:
>  >>> 1+0
> 1
>  >>> 2-1
> 1
>  >>> 1*1
> 1
>  >>> 1/1
> 1
>  >>> 3%2
> 1
>  >>> 1e0
> 1.0
>  >>> pow(1,1)
> 1
>  >>>
> 
> That last one especially throws me. Why is 1e0 a float? Simply to cover 
> instances where NeN represents a float value with no decimal points 
> anywhere in the expression? Is the language's interpretation that 
> "dumb"? If that's the case, why doesn't pow always return a float?

1e0 denotes scientific notation.  Scientific notation is defined as an 
integer [1..9] followed by a decimal point, which then requires at least 
one digit after it.

-- 
Tim Cook
http://home.bellsouth.net/p/PWP-empyrean

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
D++(---) G(++) e*>++ h+ !r--- !y--
------END GEEK CODE BLOCK------


Post a reply to this message

From: Warp
Subject: Re: Why is 1e0 a float?
Date: 31 Oct 2007 08:22:03
Message: <4728817b@news.povray.org>
Shay <Sha### [at] cccc> wrote:
> Why is 1e0 a float?

  For the exact same reason that 1.0 is a float? The language specifies
that a literal in the for "AeB" is a float?

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.