<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Say what? Microsoft Malaysia One ISV Technology Blog : BNM's rounding mechanism exercise</title><link>http://blogs.msdn.com/fai/archive/tags/BNM_2700_s+rounding+mechanism+exercise/default.aspx</link><description>Tags: BNM's rounding mechanism exercise</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>A better alternative to solving the rounding mechanism in your apps</title><link>http://blogs.msdn.com/fai/archive/2008/06/11/a-better-alternative-to-solving-the-rounding-mechanism-in-your-apps.aspx</link><pubDate>Wed, 11 Jun 2008 06:45:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8590776</guid><dc:creator>hoongfai</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/fai/comments/8590776.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fai/commentrss.aspx?PostID=8590776</wfw:commentRss><description>&lt;p&gt;Awhile back, I wrote a &lt;a href="http://blogs.msdn.com/fai/archive/2008/04/10/rounding-mechanism-exercise-how-to-mitigate-the-impact-on-isv-solutions.aspx"&gt;blog post on the rounding mechanism&lt;/a&gt;, little did I know that a reader posted a better alternative in the comments (I should read keep track of the comments closely in the future). I haven't tested this, but I trust the contributor of this piece of code. Full credit goes to &lt;a href="http://blogs.msdn.com/user/Profile.aspx?UserID=135005"&gt;gohsianghwee&lt;/a&gt; for posting this, and I quote him:&lt;/p&gt; &lt;p&gt;There is a better alternative, pass in the value 1234.23 and round digit as 2 will solve your problem. This algorithm makes user definable rounding possible. In fact, I just showed you one of my rounding mechanism in my application, which all rounding mechanism in my application are user definable.&lt;/p&gt; &lt;p&gt;User must always use decimal in terms of dollar and cent calculation. Even though decimal is not a primitive type, but it handles the calculation more appropriately compared to the others. This is due to how .NET handles primitive type figures.  &lt;p&gt;public static decimal RoundAmount(decimal roundValue, decimal roundDigit) &lt;p&gt;{ &lt;p&gt;decimal totalValue = 0; &lt;p&gt;decimal powerValue = 0; &lt;p&gt;powerValue = (decimal)(System.Math.Pow(10, (double)roundDigit)); &lt;p&gt;decimal tempDecimalValue = 5 / powerValue; &lt;p&gt;decimal rndFigure = roundValue / tempDecimalValue; &lt;p&gt;totalValue =(decimal)(System.Math.Round(rndFigure, 0)) * tempDecimalValue; &lt;p&gt;return totalValue; &lt;p&gt;} &lt;p&gt;Thanks!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8590776" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fai/archive/tags/ISV/default.aspx">ISV</category><category domain="http://blogs.msdn.com/fai/archive/tags/BNM_2700_s+rounding+mechanism+exercise/default.aspx">BNM's rounding mechanism exercise</category><category domain="http://blogs.msdn.com/fai/archive/tags/rounding+mechanism/default.aspx">rounding mechanism</category><category domain="http://blogs.msdn.com/fai/archive/tags/Decimal.Round_2800_Decimal/default.aspx">Decimal.Round(Decimal</category><category domain="http://blogs.msdn.com/fai/archive/tags/MidpointRounding_2900_/default.aspx">MidpointRounding)</category></item><item><title>Arrghh, why does Virtual PC technology exist in the first place?</title><link>http://blogs.msdn.com/fai/archive/2008/04/07/arrghh-why-does-virtual-pc-technology-exist-in-the-first-place.aspx</link><pubDate>Mon, 07 Apr 2008 11:58:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8364778</guid><dc:creator>hoongfai</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/fai/comments/8364778.aspx</comments><wfw:commentRss>http://blogs.msdn.com/fai/commentrss.aspx?PostID=8364778</wfw:commentRss><description>&lt;p&gt;LOL, I reckon that a blog post title like this is sure to attract your attention to read this. My apologies, this blog post is not about condemning Virtual PC technology. I love to use VPCs! I run VPCs everyday.&lt;/p&gt; &lt;p&gt;If you are a regular user of VPCs, I bet it crosses your mind as to why VPC instances run so sluggishly that you start to curse at the technology itself. Why does it even exist in the first place?&lt;/p&gt; &lt;p&gt;Let's not debate that, we all know that VPCs have its own advantages. To me, it helps to emulate an OS environment that I do not own, or that it emulates a particular software environment which I do not wish to install in my host OS, among others. Being a regular user of VPCs, I would like to share with you my experience using VPCs, hopefully it helps you too.&lt;/p&gt; &lt;p&gt;Here are my 5 cents ( taking into consideration the &lt;a href="http://www.bnm.gov.my/index.php?ch=209&amp;amp;pg=657&amp;amp;ac=567" target="_blank"&gt;rounding mechanism exercise&lt;/a&gt; which takes effect in Malaysia starting 1 April, 2008. To represent some value to my blog readers, I choose to round up instead): &lt;p&gt;VPC instances can be optimized a number of ways &lt;p&gt;1. Have a processor that supports &lt;b&gt;hardware virtualization&lt;/b&gt;. It does matter! See the diagram below: &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image002_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image002_thumb.jpg" width="343" border="0"&gt;&lt;/a&gt; &lt;p&gt;2. As you could see, there's an option in the VPC settings that allows hardware-assisted virtualization if your processor supports it. Unfortunately, in my case even my notebook PC does not support that. My processor configuration is as follows: &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image004_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="96" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image004_thumb.jpg" width="323" border="0"&gt;&lt;/a&gt; &lt;p&gt;According to Scott's blog, and I quote him: &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;If you're running Intel, &lt;/em&gt;&lt;a href="http://www.intel.com/products/processor_number/index_sitelet_view2.htm"&gt;&lt;em&gt;refer to this table at Intel to see if your chip supports VT&lt;/em&gt;&lt;/a&gt;&lt;em&gt;. All the Core Duos support VT except the ones that end in "E" like the Intel Core Duo processor T2300E .&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;3. In no particular order, you should check the &lt;a href="http://www.intel.com/technology/virtualization/index.htm" target="_blank"&gt;Intel Virtualization Technology (VT) web site&lt;/a&gt; to find out what processor supports hardware-assisted virtualization, also known as "Virtualization Inside" (cool name). Also check out &lt;a href="http://www.amd.com/us-en/Processors/ProductInformation/0,,30_118_8796_14287,00.html" target="_blank"&gt;AMD virtualization&lt;/a&gt; technology. I do not take sides, as I have processors from both AMD and Intel. &lt;p&gt;4. My home PC has an &lt;a href="http://www.amd.com/us-en/Processors/ProductInformation/0,,30_118_9485_13041,00.html" target="_blank"&gt;AMD Athlon 64 X2 Dual-Core processor&lt;/a&gt; and it supports hardware-assisted&amp;nbsp; virtualization. Whenever I am preparing my demo on a VPC image, I work from home (a valid reason to my boss that I have to work from home) &lt;p&gt;5. &lt;b&gt;Memory allocation&lt;/b&gt;: In the above VPC instance, I had 1.6GB of memory allocated to my VPC instance. In my home PC, I allocate 2GB, or more if I do not run many applications in the background. Size does matter. &lt;p&gt;6. &lt;b&gt;Do not run your VPC on the same hard disk as your host OS&lt;/b&gt;. Run your VPC on an external HDD that has a high RPM speed. Or if you PC has two separate physical HDDs, run and store your VPC on the HDD that is not where your host OS is installed. I am using an external Maxtor HDD with an external power source. Do not use those tiny 2.5" pocket HDD that draws power from another USB port. The power from another USB port is not enough to juice it up, besides most likely the RPM speed of the pocket HDD is low. &lt;p&gt;7. I &lt;b&gt;compress the folder which contains my VPC image&lt;/b&gt;. The reason behind this is not just because I want to optimize my storage space, but even more importantly is the fact that I want to reduce the amount of disk reads from the HDD. It's better to let my CPU work hard rather than my HDD work hard. Everyone knows that the weakest link in terms of the performance of a PC is the HDD. &lt;p&gt;8. This is how I compress the folder, right-mouse click on the folder and choose Properties: &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image006_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="219" alt="clip_image006" src="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image006_thumb.jpg" width="294" border="0"&gt;&lt;/a&gt; &lt;p&gt;9. You should also &lt;strong&gt;compact your VPC image &lt;/strong&gt;(I don't do this as often as I should though). Here's how: &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image008_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="230" alt="clip_image008" src="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image008_thumb.jpg" width="295" border="0"&gt;&lt;/a&gt; &lt;p&gt;10. If you are running your VPC on Windows Server 2003, for instance, &lt;b&gt;&lt;a href="https://www.microsoft.com/windowsserversystem/virtualserver/default.aspx" target="_blank"&gt;use Microsoft Virtual Server 2005 R2&lt;/a&gt;&lt;/b&gt; instead. &lt;p&gt;If you want to read more about VPC optimization, you may check out the following blogs: &lt;p&gt;&lt;a href="http://www.hanselman.com/blog/VirtualPCTipsAndHardwareAssistedVirtualization.aspx" target="_blank"&gt;Scott Hanselman&lt;/a&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/virtual_pc_guy/archive/2006/03/14/550712.aspx" target="_blank"&gt;The Virtual PC Guy&lt;/a&gt; &lt;p&gt;Have fun! Tomorrow I will be presenting a session called "Defy occasionally connected challenges with smart client applications that shine" (*phew* yes I admit it is a mouthful), and practicing what I've just mentioned, LIVE, at  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="58" alt="image" src="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/image_thumb.png" width="173" border="0"&gt;&lt;/a&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image002%5B6%5D.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="462" alt="clip_image002[6]" src="http://blogs.msdn.com/blogfiles/fai/WindowsLiveWriter/ArrghhwhatdoesVirtualPCtechnologyexistin_E943/clip_image002%5B6%5D_thumb.jpg" width="480" border="0"&gt;&lt;/a&gt; &lt;p&gt;See you there! &lt;p&gt;&lt;u&gt;If you're an ISV in Malaysia and your application is affected by the rounding mechanism exercise, I will have a few suggestions of my own in a follow-up blog post.&lt;/u&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8364778" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/fai/archive/tags/VPC+optimization/default.aspx">VPC optimization</category><category domain="http://blogs.msdn.com/fai/archive/tags/VT/default.aspx">VT</category><category domain="http://blogs.msdn.com/fai/archive/tags/BNM_2700_s+rounding+mechanism+exercise/default.aspx">BNM's rounding mechanism exercise</category></item></channel></rss>