The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Archive for October, 2013

Delphi – Direct3D and the wrong FPU state: Now() function returns a wrong value (via: StackOverflow)

Posted by jpluimers on 2013/10/31

The question datetime – Delphi Now() function returns a wrong value – Stack Overflow is similar to my article Delphi – Michael Justin had strange floating point results when his 8087 FPU Control Word got hosed.

Good that stackoverflow user Anton Zhuchkov found out the cause himself: his answer indicates the Precision Control (and rounding) part of the FPU state got hosed by wrongly initializing the Direct3D device.

I edited his answer with some extra links to documentation.

Finally I’ve found the solution. I needed to specify the D3DCREATE_FPU_PRESERVE flag when creating a D3D device by D3D.CreateDevice.

Otherwise, without that flag, all floating point operations are performed with single precision. As the TDateTime is a simple Double, and Now() functions is consist of simple addition of date value to time value, it all get messed up by DirectX “smart” override.

Problem solved. It was a tricky one indeed. :)

–jeroen

via: datetime – Delphi Now() function returns a wrong value – Stack Overflow.

Posted in 8087, Algorithms, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Development, Floating point handling, Software Development | 2 Comments »

Some links for scripting SQL Server Backups and setting up maintenance plans

Posted by jpluimers on 2013/10/30

I need to do some research to automate the backups and restore sequences of some SQL Servers.

Here are some links and notes to get started:

Posted in Database Development, Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | Leave a Comment »

Interesting SO question: What are the experiences with using unicode in identifiers?

Posted by jpluimers on 2013/10/29

Toon Krijthe posted an interesting question to SO.

Though 5 years old, I think it stilll is very valid one:

At my work, we have decided to stay with the ANSI characters for identifiers. Is there anybody out there using unicode identifiers and what are the experiences?

For all projects I work on (in various Languages like  English, German, Dutch or other), I stick to ASCII characters (not even ANSI) for:

  • file names
  • identifiers

I also try to abstract the non-ASCII strings into places where I am sure that the encoding is preserved (for text files, I prefer UTF-8), or where these characters are properly escaped.

What is your take on this?

–jeroen

via: uniqueidentifier – What are the experiences with using unicode in identifiers – Stack Overflow.

Posted in .NET, Agile, AS/400 / iSeries / System i, C, C#, C++, COBOL, Continuous Integration, Delphi, Development, F#, Prism, Scripting, Software Development, VB.NET, Visual Studio and tools | 4 Comments »

In my list of things to try: Quilla › Short-links for email.

Posted by jpluimers on 2013/10/28

Quilla › Short-links for email..

Should try this soon.

–jeroen

Posted in Power User | Leave a Comment »

HP xw6600 Workstation – The Computer Setup F10 Utility: enabling Intel VT so you can run VMware ESXi or vSphere on it

Posted by jpluimers on 2013/10/25

On a HP XW6600, you can run ESXi 4 or run ESXi 5, but in yourder to run x64 guest VMs, you need to enable Intel VT in the BIOS first.

So, in the HP XW6600 BIOS, the choose the menu “Security”, then the submenu “OS Security” to get at these two options:

  • Intel Virtualization Technology (VTx)—Enables or disables Intel Virtualization Technology to increase workstation performance.
  • Intel IO Virtualization—Enables or disables Virtualization Technology to increase workstation I/O performance.

When you enable both VT options, then VMware ESX/ESXi/vSphere can run x64 guests with full VT support (otherwise you will get a friendly warning message when you try to setup or run such a guest VM). Read the rest of this entry »

Posted in BIOS, Boot, ESXi4, ESXi5, ESXi5.1, Hardware, HP XW6600, Power User, Virtualization, VMware, VMware ESXi | 3 Comments »

SQL Server: “there’s nothing so permanent as temporary”

Posted by jpluimers on 2013/10/24

“there’s nothing so permanent as temporary” can apply to many things, for instance Kitchen and software development (there technical debt is very applicable), the financial top gap measures (which are real debt) of fanfiction. You can apply it to SQL Server as well. The TempDBhas been there since before SQL Server 7, which means it has established a permanent feature for quite some time now.

Your DBA (which might be you) needs to watch the temdb size or space on the separate volume where temdb is stored, or someday the TemDB access patterns will cause havoc.

The most used feature (there are more) in TempDB is temporary tables (often abbreviated to “temp tables”), which – since TemDB got there – has come in three flavours:

The table variables are created and released implicitly. The temporary tables (one of the Special Table Types) can be created either explicitly using a CREATE TABLE, or implicitly using SELECT … INTO. You’d think that temporary tables are indeed temporary. But they are not:

Temporary tables are semi-temporary. Not actually permanent,  but not fully temporary either.

All flavours of temporary tables are not being fully deleted when they go out of scope. When they go out ot scope, they will get an implicit/automatic truncate to empty them (so there is no manual TRUNCATE TABLE or DROP TABLE needed). But the table itself lives on including any cached plan information. They can, and often will be reused. And that’s where you should start reading these links:

One more thing: as of SQL Server 2012, the OBJECT_ID associated with temporary tables is negative.

–jeroen

via:

Posted in Database Development, Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 7 | 2 Comments »

Tables with SQL Server and .NET data types

Posted by jpluimers on 2013/10/23

Thanks StackOverflow users George Stocker for asking, Örjan Jämte and Sir Crispalot for answering.

Below is the SQL Server 2012 table, in which I added links to the various data types.

I also added two columns with linked references to the types from the  C# data typesC# KeywordsReference Tables for Types (C# Reference) and Data Type Summary (Visual Basic).

One of the things I need to check is against the LINQ SQL-CLR Type Mapping.

It is very important to keep in mind that in SQL, each combination of precision and digits gets you a different decimal type, and all of them are different from the .NET decimal type. See for instance the answers on these questions:

Read the rest of this entry »

Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Algorithms, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Database Development, Development, Floating point handling, Software Development, SQL Server, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »

.NET/C#: Type.IsSubclassOf Method versus Type.IsAssignableFrom

Posted by jpluimers on 2013/10/22

Every once in a while, you will have to do is checks using reflection.

Basically there are two methods:

Thanks to Ani and Werner Beroux for explaining the difference in more detail on StackOverflow, I added some extra links:

To check for assignability, you can use the Type.IsAssignableFrom method:

typeof(SomeType).IsAssignableFrom(typeof(Derived))

This will work as you expect for

but not when you are looking for ‘assignability’ across explicit / implicit conversion operators.

To check for strict inheritance, you can use Type.IsSubclassOf:

typeof(Derived).IsSubclassOf(typeof(SomeType))

–jeroen

via: c# – How to check if a class inherits another class without instantiating it? – Stack Overflow.

Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »

Table with the Numeric Data Types in SQL Server

Posted by jpluimers on 2013/10/22

I couldn’t find a table with numeric data types in SQL Server 2012 on MSDN, but since they have not changed since SQL Server 2008,  I copied the table from Understand the 9 Numeric Data Types in SQL Server 2008, added an entry for bit, and links to the relevant SQL Server 2012 pages at MSDN.

Edit: somehow the WordPress editing system suppressed all the superscripts (for the powers of 2 and 10), so I replaced them with caret signs and powers of 2 and 10 to make it more clear and verified them against Floating point numbers and these Wikipedia pages:

Data Type Range of Values Storage Space

Data Type Range of Values Storage Space
tinyint 0 to 255 1 byte
smallint –32,768 to 32,767 2 bytes
int –2^31 to 2^31–1 4 bytes
bigint –2^63 to 2^63–1 8 bytes
decimal(p,s)
numeric(p,s)
–10^38+1 to 10^38–1 5 to 17 bytes
smallmoney –214,748.3648 to 214,748.3647 4 bytes
money –922,337,203,685,477.5808 to 922,337,203,685,477.5807 8 bytes
real –3.4*10^38 to –1.18*10^38, 0, and 1.18*10^38 to 3.4*10^38 4 bytes
float(n) –1.79*10^308 to –2.23*10^308, 0, and 2.23*10^308 to 1.79*10^308 4 bytes or 8 bytes
bit 0 to 1 0+ bytes

Later I found an even more complete table at SQL Server Data Types Reference – ConnectionStrings.com.

–jeroen

via: Understand the 9 Numeric Data Types in SQL Server 2008.

Posted in Algorithms, Database Development, Development, Floating point handling, Software Development, SQL Server, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »

Want this (: Floppy Table, A Wonderfully Designed 3.5″ Floppy Disk Coffee Table

Posted by jpluimers on 2013/10/21

If you recognize this picture

then you likely love this FloppyTable designed and created by Neulant van Exel and made of 2 kinds of welded steel:

Read the rest of this entry »

Posted in About, Opinions, Personal, Power User | Leave a Comment »