1. #### Nanoseconds

According to answers.com a nanosecond is:
Code:
`One billionth (10**-9) of a second.`
Don't mis-read the exponential within the code tags. Anyways, I'm working with C++ FILETIME structures however I need to use a likelyness of them in Python. There is a certain function which I must create that uses C++ functions such as GetLocalTime() and GetSystemTime(). I've got these functions writen in Python already, since they are easy. The problem is that I cannot convert both of these values into FILETIME structures. Note: It wouldn't be called "structure" in Python. According to MSDN a FILETIME is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC). My main concern is retrieving the value of a nanosecond in Python. I'm not sure if it is even possible. If it is not, I will attempt to find a way around this, if it is possible, please show me how to do it or give me an idea. Any help is appreciated.

Edit: Somewhat solved.
I used 10**-9 for a nanosecond. I completely forgot about Python having access to exponential values.
Last edited by †Yegg†; August 22nd, 2005 at 05:17 PM.
2. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2004
Posts
394
Rep Power
55
Hi!

Just one quick note: instead of 10**-9 use 1e-9, that's the way to write exponentials in Python

Regards, mawe
3. Well, I guess it is. But it still returns the same value.
4. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2004
Posts
394
Rep Power
55
I know that it returns the same value, but IMO 10**-9 looks ugly (and is probably slower, I'm not sure).
5. No Profile Picture
Contributing User
Devshed Intermediate (1500 - 1999 posts)

Join Date
Feb 2004
Location
London, England
Posts
1,585
Rep Power
1377
Originally Posted by mawe
I know that it returns the same value, but IMO 10**-9 looks ugly (and is probably slower, I'm not sure).
Yes it is:
Code:
```\$ python -m timeit '10**-9'
1000000 loops, best of 3: 1.75 usec per loop

\$ python -m timeit '1e-9'
10000000 loops, best of 3: 0.136 usec per loop

\$ python -m timeit '1'
10000000 loops, best of 3: 0.133 usec per loop```
10**-9 will calculate the value every time it is encountered, while 1e-9 will be calculated once at compile time - from the above timings, you can see that 1e-9 takes the same time to evaluate as 1.

Dave - The Developers' Coach

#### Comments on this post

• Grim Archon agrees : The 1e-9 format is the convention for small numbers.
6. I guess you guys are right. I'll use 1e-9 instead. Thanks.