C# DivideByZeroException

Uncategorized No Comments »

While doing some unit tests this morning I realised that something very weird was happening… I did not know why but I was able to divide by zero!

The code below is an example of some that I was expecting to throw  DivideByZeroException

int a = 0;
int b = 0;
int c = a / b; // <—- DivideByZeroException is thrown here

That works fine, as it is exactly the expected behaviour, but look at this 2 very similar code blocks below

double a = 0;
double b = 0;
double c = a / b; // <—– Nothing happens. a = 0, so c = double.NaN

float x = 1;
float y = 0;
float z = x / y; // <—- Nothing happens. x =1, so z = float.Infinity

I was very surprised, so after checking MSDN I got the answer to this “mystery”: Standards

The DivideByZeroException Class documentation is very clear about this topic:

“The exception that is thrown when there is an attempt to divide an integral or decimal value by zero.” and “Dividing a floating-point value by zero will result in either positive infinity, negative infinity, or Not-a-Number (NaN) according to the rules of IEEE 754 arithmetic. Floating-point operations never throw an exception”.

The .NET Framework just follow the arithmetic standard, and we all know that Standards are nice! I just don’t like that there are so many of them.

 thumbs_up And thumbs up for MSDN.

IE8 incompatibility list

Uncategorized No Comments »

The following list shows a some of the sites that have compatibility problems with Internet explorer 8:

  • microsoft.com
  • live.com
  • msn.com.cn
  • yahoo.com
  • cctv.com
  • google.com
  • wikipedia.org
  • flickr.com
  • wordpress.com
  • adobe.com
  • facebook.com
  • apple.com
  • youtube.com
  • imdb.com
  • thepiratebay.org
  • dell.com
  • netflix.com
  • nytimes.com
  • gizmodo.com
  • kotaku.com
  • sony.com

View the complete list (with more than 2400 items) at ZDNet

[source: saporra (google translated)]

50 Useful JavaScript Tools

Uncategorized No Comments »

50 Javascript tools to help development.

logo

[source: AjaxRain]

if(navigator.userAgent.indexOf(’MSIE’)!=-1){window.close();}

Web Development 1 Comment »

IE8 bug

A few days ago I said for you guys to update your browser to make web developers life easier, but it seems that IE8 is following his older brother steps, at least until now (RC1 version), which means that web development is about to become more challenging.

I was hoping that IE8 would significantly reduce the number of brave/stupid/I don’t know why someone still use this crap IE6 users, however, I must confess that I am concerned with the idea that IE8 could cause even more headaches. Some issues are reported by Michael Dayah (from ptable.com), who described some problems while trying to render elements that Microsoft is marking as “won’t fix” and also kangax, that reported that a single JavaScript line can crash the browser.

Besides all that, IE8 is still the slowest among big browsers (almost 35% more than the second slowest: Opera), of course that Microsoft continues to dismiss benchmarks like this. Anyway, who cares about performance? Do you remember Windows Vista?

source: AjaxRain

UPDATE: MSDN provides a lot of information regarding the migration to IE8 tha you can find following this link.  Some informations provided are very useful, such as if you find some issue that you can not fix or find a workaround for, you can make you page to be rendered as IE7 placing the following HTML META tag into the HEAD element of each Web page (before tags other than TITLE or META):

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>

The F Word

Fun No Comments »
The F Word

The F Word

Mac completes 25 years

Apple No Comments »

It was 1984 when people saw for the very first time the Apple Macintosh ad and then a new era began.

With the following configuration:

  • CPU 68000
  • 128KB RAM
  • 64KB ROM
  • 400KB Floppy
  • 512×342 pixels
  • 9” monitor

It was a computer that could even introduce itself

Happy birthday Mac! I guess that even Bill Gates is happy for you today.

Check out the new ads if you want to laugh more.

source: Techcrunch

Vista = ME2 (Mistake Edition 2)

Windows 2 Comments »

windows_74

I really don’t know how some developers can do their work using Windows Vista.

I must say that Vista is beautiful with all those new usability features (even if some of then copied from Mac OS, but they still are new features) and is also safe, even if being safe means having a lot of popup messages annoying you all the time, however,  even Microsoft recommends that Windows ME2 Vista users should follow Microsoft performance guide and that can not be a good sign.Calvin Vista

Although some friends of mine still try to convince me that Windows Vista performance is not that bad *, almost all internet community complains about Vista performance, even with most of new computers having their hardware optimized for Vista usage, which is something very interesting.

Truth must be told:  Windows 95 +12 years Vista sucks ** and I am also really glad I am not a Vista salesperson!

Lets wait for Windows 7 to hopefully erase this Vista image and make we think of Vista as a Microsoft dark phase, just as happened with Windows ME.

[UPDATE] I really think we will see Vista in this list a few years from now: Top 10 worst products

* http://www.tecnocrata.com.br/?p=78 (English translated page)

** http://www.kareldonk.com/karel/2008/01/11/bill-gates-windows-vista-sucks/ AND http://www.breakitdownblog.com/why-vista-sucks/

Development Tip of the Day

Tips 1 Comment »

Always code as if the person that will maintain your code is a maniac serial killer that knows were you live

“Always code as if the person that will maintain your code is a maniac serial killer that knows were you live” *

Every developer should have this image as a wallpaper.

* http://www.myconfinedspace.com/

Upgrade your outdated browser

Web Development 2 Comments »

Developers are still losing too much time trying to make everything work fine in old browsers that do not support must of the new features and technologies.

IE6 still holds 20% of internet users* and it is a browser that is not compatible with the current internet evolution stage, besides having security problems that can be harmful to any unadvised user.

If you are using an uptaded browser you probably have not noticed, but this blog is now helping to Pushup the web, all users with an outdate browser will see a notice here warning them to upgrade their browser, as you can see the message clicking here.

Help internet to become even better, be a part of that campaign.

Brazilian Portuguese websites can also join the Imasters campaign “Atualize seu navegador

If your country has some special campaign translated to portuguese please let me know to add to this post.

* http://www.w3schools.com/browsers/browsers_stats.asp

Sabino’s Lab and blog Project launched

Web Development No Comments »

This is the very first post of this Blog, and is dedicated exclusively to a new component source for the web development community: Sabino’s Lab

Sabino’s Lab is my personal project which has a simple proposal: Provide good, simple and useful web-based components.

This project starts with 2 simple but useful Javascript components fully documented and with examples of how to use then:

  • The first is a Timer class implementation, which implements both ’setTimeout’ and ‘clearTimeout’ functions internally but with a much simplified usage, besides the ability to have a certain number of loops and some extra information as elapsed time and number of completed loops.
  • The second is a more elaborated one, which is a logging script for Javascript developers. A good thing about this component is the ability to leave the log calls in the developer source without compromising performance as you are able to remove almost completely the logging intelligence, without impact in you script.

I am always looking for feedback on how to improve all components and this blog.

Take a moment to provide me your feedback.

Thanks,

Felipe Sabino

Copyright © 2008 Felipe Sabino. Theme by N.Design Studio
Entries RSS Comments RSS Log in