---
title: "Funny Behaviour"
url: "https://osherove.com/blog/2003/6/16/funny-behaviour.md"
canonical: "https://osherove.com/blog/2003/6/16/funny-behaviour.html"
published: "2003-06-16T11:17:00"
updated: "2003-06-16T11:17:00"
tags: [".Net Original"]
author: "Roy Osherove"
description: "Tamar, a friend of mine, alerted me to this funny behaviour. can anyone tell me why the following code: static void Main(string[] args) { Console.WriteLine(21 - 5.45); Console.WriteLine(21 - 20.45); Console.Read(); }…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Funny Behaviour

By Roy Osherove June 16, 2003 In [.Net Original](https://osherove.com/blog/category/net-original)

**Historical article** · Originally published June 16, 2003; technical details may be outdated.

Tamar, a friend of mine, alerted me to this funny behaviour.

can anyone tell me why the following code:

static void Main(string\[\] args)

{

Console.WriteLine(21 - 5.45);

Console.WriteLine(21 - 20.45);

Console.Read();

}

produces this:

15.55
0.550000000000001

This happens in C#,VB.NET and VB6.  What's going on here?

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- Jun 19, 2003

    ### [How To Know When An External Application Exits](https://osherove.com/blog/2003/6/19/how-to-know-when-an-external-application-exits.html)

- Jun 19, 2003

    ### [Winforms DataBinding Bliss](https://osherove.com/blog/2003/6/19/winforms-databinding-bliss.html)

- Jun 15, 2003

    ### [Data Binding Woes - A Simple Solution](https://osherove.com/blog/2003/6/15/data-binding-woes-a-simple-solution.html)

- Jun 14, 2003

    ### [Winforms Data Binding Woes](https://osherove.com/blog/2003/6/14/winforms-data-binding-woes.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
