This doesn't work:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = b - a
sets ans to 0 instead of 1 million. You have to do this:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = (DirectCast(b, Long) - DirectCast(a, Long))
to get around it. Although is there a more elegant way?
Phill 6 1235
On Mar 3, 6:20 pm, Phillip Taylor <Phillip.Ross.Tay...@gmail.com>
wrote:
This doesn't work:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = b - a
sets ans to 0 instead of 1 million. You have to do this:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = (DirectCast(b, Long) - DirectCast(a, Long))
to get around it. Although is there a more elegant way?
Phill
instead of ten million*
The first code snippet works fines here ??? (.NET 2.0). How do you see the
value for ans ?
--
Patrice
"Phillip Taylor" <Ph*****************@gmail.coma écrit dans le message de
news: b7**********************************...oglegroups.com...
This doesn't work:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = b - a
sets ans to 0 instead of 1 million. You have to do this:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = (DirectCast(b, Long) - DirectCast(a, Long))
to get around it. Although is there a more elegant way?
Phill
On Mar 3, 8:20 pm, Phillip Taylor <Phillip.Ross.Tay...@gmail.com>
wrote:
This doesn't work:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = b - a
sets ans to 0 instead of 1 million. You have to do this:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = (DirectCast(b, Long) - DirectCast(a, Long))
to get around it. Although is there a more elegant way?
Phill
Tried "Dim ans As Long = b - a" and "Dim ans As Long = (DirectCast(b,
Long) - DirectCast(a, Long))" and they both outputs the same: 10000000
Couldn't notice a difference.
Works fine here, with option strict both on and off.
Tom Dacon
Dacon Software Consulting
"Phillip Taylor" <Ph*****************@gmail.comwrote in message
news:b7**********************************@e31g2000 hse.googlegroups.com...
This doesn't work:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = b - a
sets ans to 0 instead of 1 million. You have to do this:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = (DirectCast(b, Long) - DirectCast(a, Long))
to get around it. Although is there a more elegant way?
Phill
"Phillip Taylor" <Ph*****************@gmail.comschrieb:
This doesn't work:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = b - a
sets ans to 0 instead of 1 million. You have to do this:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = (DirectCast(b, Long) - DirectCast(a, Long))
to get around it. Although is there a more elegant way?
Both code samples produce the same result.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
On Mar 4, 2:09 am, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
"Phillip Taylor" <Phillip.Ross.Tay...@gmail.comschrieb:
This doesn't work:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = b - a
sets ans to 0 instead of 1 million. You have to do this:
Dim t As DateTime = DateTime.Now
Dim a As Long = t.Ticks
Dim t2 As DateTime = t.AddSeconds(1)
Dim b As Long = t2.Ticks
Dim ans As Long = (DirectCast(b, Long) - DirectCast(a, Long))
to get around it. Although is there a more elegant way?
Both code samples produce the same result.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Hmmm I am unable to replicate this bug today...
:-s This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: kartik |
last post by:
there seems to be a serious problem with allowing numbers to grow in a
nearly unbounded manner, as int/long unification does: it hides bugs.
most of the time, i expect my numbers to be small. 2**31...
|
by: w3r3w0lf |
last post by:
hello!
I have a following situation:
I have a byte array where at a certain location are stored 4 bytes, and
these should be "put" into long variable (or any other 4 byte one).
ie:
byte...
|
by: Master of C++ |
last post by:
Hello Folks,
I have a programming dilemma with templates and "genericity". I can
think of a few solutions, but I am not sure which one is the best in
terms of genetic C++ style. Any suggestions...
|
by: RB |
last post by:
How to extract bytes from long, starting from the last byte?
For example, I have a long number:
0x12345678
I need to represent it as the following bytes list:
0x78, 0x56, 0x34, 0x12
Thanks in...
|
by: Peter Ammon |
last post by:
When I add an unsigned long long and an int, what type do each of the
values get promoted to before the addition is performed? What is the
type of the resulting expression? What occurs if the...
|
by: Peter Olcott |
last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html
The above link shows that C# is 450% slower on something as simple as a nested
loop....
|
by: David Geering |
last post by:
Is there any standard as to what a long and int mean or is it compiler
dependent? Or furthermore architecture dependent?
I know a short short long int isn't actually a recognised type, but if you...
|
by: krunalb |
last post by:
Hi,
I am trying to shift unsigned long long value by 64 bits and this is
what i get
#include <stdio.h>
int main()
{
unsigned short shiftby= 64;
|
by: Bartc |
last post by:
From an article about implementing a C99 to C90 translator...
How does someone use integer arithmetic of at least 64 bits, and write in
pure C90?
As I understand C90 (the standard is very...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |