Oren Eini

aka Ayende Rahien

Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

oren@ravendb.net +972 52-548-6969

Posts: 7,575
|
Comments: 51,188

Copyright ©️ Ayende Rahien 2004 — 2025

Privacy Policy · Terms
filter by tags archive
stack view grid view
  • architecture (606) rss
  • bugs (450) rss
  • challanges (123) rss
  • community (377) rss
  • databases (481) rss
  • design (893) rss
  • development (640) rss
  • hibernating-practices (71) rss
  • miscellaneous (592) rss
  • performance (397) rss
  • programming (1085) rss
  • raven (1442) rss
  • ravendb.net (526) rss
  • reviews (184) rss
  • 2025
    • May (7)
    • April (10)
    • March (10)
    • February (7)
    • January (12)
  • 2024
    • December (3)
    • November (2)
    • October (1)
    • September (3)
    • August (5)
    • July (10)
    • June (4)
    • May (6)
    • April (2)
    • March (8)
    • February (2)
    • January (14)
  • 2023
    • December (4)
    • October (4)
    • September (6)
    • August (12)
    • July (5)
    • June (15)
    • May (3)
    • April (11)
    • March (5)
    • February (5)
    • January (8)
  • 2022
    • December (5)
    • November (7)
    • October (7)
    • September (9)
    • August (10)
    • July (15)
    • June (12)
    • May (9)
    • April (14)
    • March (15)
    • February (13)
    • January (16)
  • 2021
    • December (23)
    • November (20)
    • October (16)
    • September (6)
    • August (16)
    • July (11)
    • June (16)
    • May (4)
    • April (10)
    • March (11)
    • February (15)
    • January (14)
  • 2020
    • December (10)
    • November (13)
    • October (15)
    • September (6)
    • August (9)
    • July (9)
    • June (17)
    • May (15)
    • April (14)
    • March (21)
    • February (16)
    • January (13)
  • 2019
    • December (17)
    • November (14)
    • October (16)
    • September (10)
    • August (8)
    • July (16)
    • June (11)
    • May (13)
    • April (18)
    • March (12)
    • February (19)
    • January (23)
  • 2018
    • December (15)
    • November (14)
    • October (19)
    • September (18)
    • August (23)
    • July (20)
    • June (20)
    • May (23)
    • April (15)
    • March (23)
    • February (19)
    • January (23)
  • 2017
    • December (21)
    • November (24)
    • October (22)
    • September (21)
    • August (23)
    • July (21)
    • June (24)
    • May (21)
    • April (21)
    • March (23)
    • February (20)
    • January (23)
  • 2016
    • December (17)
    • November (18)
    • October (22)
    • September (18)
    • August (23)
    • July (22)
    • June (17)
    • May (24)
    • April (16)
    • March (16)
    • February (21)
    • January (21)
  • 2015
    • December (5)
    • November (10)
    • October (9)
    • September (17)
    • August (20)
    • July (17)
    • June (4)
    • May (12)
    • April (9)
    • March (8)
    • February (25)
    • January (17)
  • 2014
    • December (22)
    • November (19)
    • October (21)
    • September (37)
    • August (24)
    • July (23)
    • June (13)
    • May (19)
    • April (24)
    • March (23)
    • February (21)
    • January (24)
  • 2013
    • December (23)
    • November (29)
    • October (27)
    • September (26)
    • August (24)
    • July (24)
    • June (23)
    • May (25)
    • April (26)
    • March (24)
    • February (24)
    • January (21)
  • 2012
    • December (19)
    • November (22)
    • October (27)
    • September (24)
    • August (30)
    • July (23)
    • June (25)
    • May (23)
    • April (25)
    • March (25)
    • February (28)
    • January (24)
  • 2011
    • December (17)
    • November (14)
    • October (24)
    • September (28)
    • August (27)
    • July (30)
    • June (19)
    • May (16)
    • April (30)
    • March (23)
    • February (11)
    • January (26)
  • 2010
    • December (29)
    • November (28)
    • October (35)
    • September (33)
    • August (44)
    • July (17)
    • June (20)
    • May (53)
    • April (29)
    • March (35)
    • February (33)
    • January (36)
  • 2009
    • December (37)
    • November (35)
    • October (53)
    • September (60)
    • August (66)
    • July (29)
    • June (24)
    • May (52)
    • April (63)
    • March (35)
    • February (53)
    • January (50)
  • 2008
    • December (58)
    • November (65)
    • October (46)
    • September (48)
    • August (96)
    • July (87)
    • June (45)
    • May (51)
    • April (52)
    • March (70)
    • February (43)
    • January (49)
  • 2007
    • December (100)
    • November (52)
    • October (109)
    • September (68)
    • August (80)
    • July (56)
    • June (150)
    • May (115)
    • April (73)
    • March (124)
    • February (102)
    • January (68)
  • 2006
    • December (95)
    • November (53)
    • October (120)
    • September (57)
    • August (88)
    • July (54)
    • June (103)
    • May (89)
    • April (84)
    • March (143)
    • February (78)
    • January (64)
  • 2005
    • December (70)
    • November (97)
    • October (91)
    • September (61)
    • August (74)
    • July (92)
    • June (100)
    • May (53)
    • April (42)
    • March (41)
    • February (84)
    • January (31)
  • 2004
    • December (49)
    • November (26)
    • October (26)
    • September (6)
    • April (10)
Comparison page for RavenDB and MongoDB
  previous post next post  
Mar 28 2011

An small mistake, just by nine orders of magnitude

time to read 1 min | 47 words

Originally posted at 3/16/2011

image

Opps Sad smile

Tweet Share Share 27 comments
Tags:
  • Bugs

  previous post next post  

Comments

Patrick Huizinga
28 Mar 2011
10:40 AM
Patrick Huizinga

At first I thought it would be interpreted as if ( (copiedStream.Length > 1) * Giga)

But then I realized the compiler would give an error (about bools, ints and ifs).

And when I entered the above piece of code in VS, I was quite surprised about the actual error. :)

Lee Atkinson
28 Mar 2011
11:31 AM
Lee Atkinson

A VB programmer in a pass life, perhaps?

Martin Larsen
28 Mar 2011
11:44 AM
Martin Larsen

Hehe.. I actually spent 10 minutes staring at that snippet before realising what was wrong. :-)

Ales
28 Mar 2011
12:09 PM
Ales

Same as Martin :-) but takes 15 mins :-D

Peter Morlion
28 Mar 2011
12:18 PM
Peter Morlion

Also had to enter it in VS before I got it. Even then, had to double-check MSDN :D Learnt something new today!

SHODAN
28 Mar 2011
12:34 PM
SHODAN

If you take that long to spot the problem, you need to read some C# for dummies books.

Diego Mijelshon
28 Mar 2011
13:45 PM
Diego Mijelshon

Shodan, if you code in more than one language (I assume you've read C# for dummies, but not VB for morons, nor Haskell for idiots), it's not hard to use the wrong operator.

In that regard, C# is behind other modern languages for not having an exponentiation operator (which could just be an alias for Math.Pow), which is more useful for high-level development than XOR (and they could have used **, which doesn't clash with anything)

Remco Ros
28 Mar 2011
13:57 PM
Remco Ros

I'm going back to school. . . . ^-^

Jason
28 Mar 2011
14:35 PM
Jason

Isn't this an ugly way to do things regardless - why calculate the value every time? Why not just use const int giga = 1000000000?

Juan Lopes
28 Mar 2011
14:51 PM
Juan Lopes

That's why I prefer the "1e9" notation.

Martin Larsen
28 Mar 2011
14:54 PM
Martin Larsen

Jason, the compiler optimizes away the calculation as it is a const value.

Andrew Skalkin
28 Mar 2011
15:21 PM
Andrew Skalkin

Two minutes of blankly staring at the snippet and finally the facepalm moment :)

Christopher Bennage
28 Mar 2011
17:29 PM
Christopher Bennage

Ha! I totally would have made that mistake. :-P

Christopher Bennage
28 Mar 2011
17:30 PM
Christopher Bennage

@Jason - readability

Harry Steinhilber
28 Mar 2011
18:25 PM
Harry Steinhilber

@Juan, the only problem with the '1e9' notation is that it produces a double. Ayende's constant was an int, so it would require an additional explicit cast. Not terrible, but it does end up messing with readability.

configurator
28 Mar 2011
20:40 PM
configurator

I prefer 1 << 30. It's quite clear (everybody knows 1 << 10 is kilobyte) and I find it clearer because you have 10 for each prefix (10 = kilo, 20 = mega, 30 = giga, etc. - easier for me than 3, 6, 9).

hazzik
28 Mar 2011
21:14 PM
hazzik

Write the unit tests first, idiots!

TDD in your ass!

Brian
28 Mar 2011
22:11 PM
Brian

@hazzik, You might consider reading: How to Win Friends & Influence People

Unless, of course, you're trying to influence us to consider you in a less than stellar way.

James
29 Mar 2011
05:20 AM
James

@hazzik

Testing only proves the presence of bugs not their absence.

  • Dijkstra
Louis Hau&#223;knecht
29 Mar 2011
09:58 AM
Louis Hau&#223;knecht

+1 for @configurator.

Manu
29 Mar 2011
10:38 AM
Manu

@Diego, I believe ** would clash with pointer multiplication

Ryan Heath
29 Mar 2011
10:40 AM
Ryan Heath

@configurator minor nitpick, according to the variable name 'giga', the ( intended) value 1.000.000.000 is correct.

1 << 30 == 1 GB (GiB) == 1.073.741.824 bytes.

Just as kilo equals 1000. 1 KB (KiB) equals 1024 bytes.

// Ryan

configurator
29 Mar 2011
11:00 AM
configurator

@Ryan: I couldn't care less. When talking about file size it may be "correct" to consider a gigabyte as 1000000000 bytes, but it is standard to consider a gigabyte as 1073741824 bytes.

Ron Klein
29 Mar 2011
11:43 AM
Ron Klein

That's why I prefer "complex" consts to have the format of:

int const Kilo = 1000;

int const Mega = 1000 * Kilo;

int const Giga = 1000 * Mega;

Ryan Heath
29 Mar 2011
14:20 PM
Ryan Heath

@configurator tell that to drive manufacturers :)

They usually advertise the base 10 value compreviews.about.com/.../ActualHDSizes.htm

// Ryan

configurator
30 Mar 2011
13:39 PM
configurator

@Ryan: Yes, I'm fully aware of that. Like I said, I just don't care. When I'm talking about Gigabytes, I don't care about a 7% difference; sure, I care if something is 100GB or 200GB, but I don't give a rat's ass about that third digit.

SHODAN
06 Apr 2011
10:32 AM
SHODAN

Diego, don't take this the wrong way, but if you code in several languages you still need to know them well enough not to make these kinds of mistakes. That being said, we all make mistakes - mine was probably posting a rude comment. I apologise for that.

Comment preview

Comments have been closed on this topic.

Markdown formatting

ESC to close

Markdown turns plain text formatting into fancy HTML formatting.

Phrase Emphasis

*italic*   **bold**
_italic_   __bold__

Links

Inline:

An [example](http://url.com/ "Title")

Reference-style labels (titles are optional):

An [example][id]. Then, anywhere
else in the doc, define the link:
  [id]: http://example.com/  "Title"

Images

Inline (titles are optional):

![alt text](/path/img.jpg "Title")

Reference-style:

![alt text][id]
[id]: /url/to/img.jpg "Title"

Headers

Setext-style:

Header 1
========
Header 2
--------

atx-style (closing #'s are optional):

# Header 1 #
## Header 2 ##
###### Header 6

Lists

Ordered, without paragraphs:

1.  Foo
2.  Bar

Unordered, with paragraphs:

*   A list item.
    With multiple paragraphs.
*   Bar

You can nest them:

*   Abacus
    * answer
*   Bubbles
    1.  bunk
    2.  bupkis
        * BELITTLER
    3. burper
*   Cunning

Blockquotes

> Email-style angle brackets
> are used for blockquotes.
> > And, they can be nested.
> #### Headers in blockquotes
> 
> * You can quote a list.
> * Etc.

Horizontal Rules

Three or more dashes or asterisks:

---
* * *
- - - - 

Manual Line Breaks

End a line with two or more spaces:

Roses are red,   
Violets are blue.

Fenced Code Blocks

Code blocks delimited by 3 or more backticks or tildas:

```
This is a preformatted
code block
```

Header IDs

Set the id of headings with {#<id>} at end of heading line:

## My Heading {#myheading}

Tables

Fruit    |Color
---------|----------
Apples   |Red
Pears	 |Green
Bananas  |Yellow

Definition Lists

Term 1
: Definition 1
Term 2
: Definition 2

Footnotes

Body text with a footnote [^1]
[^1]: Footnote text here

Abbreviations

MDD <- will have title
*[MDD]: MarkdownDeep

 

FUTURE POSTS

  1. NOT Sharding RavenDB Vector Search - 3 hours from now
  2. Optimizing the cost of clearing a set - 3 days from now
  3. Scaling HNSW in RavenDB: Optimizing for inadequate hardware - 5 days from now

There are posts all the way to May 14, 2025

RECENT SERIES

  1. RavenDB News (2):
    02 May 2025 - May 2025
  2. Recording (15):
    30 Apr 2025 - Practical AI Integration with RavenDB
  3. Production Postmortem (52):
    07 Apr 2025 - The race condition in the interlock
  4. RavenDB (13):
    02 Apr 2025 - .NET Aspire integration
  5. RavenDB 7.1 (6):
    18 Mar 2025 - One IO Ring to rule them all
View all series

RECENT COMMENTS

  • But in case you have nullability checks enabled (i.e. `<Nullable>enable</Nullable>`), then you'll have a compiler warning on ...
    By Samyon Ristov on The null check that didn't check for nulls
  • Grok wasn't *wrong*. It only said that `_items` can't be null for the condition to evaluate to `true`, but didn't say anythi...
    By Johannes Egger on The null check that didn't check for nulls
  • When I started enabling NRT, I remember I was initially confused when all variables (for reference types) declared with `var`...
    By riccardo on The null check that didn't check for nulls
  • That is surprising - I think of var as a shorthand that does not affect the final result of the compilation. I wouldn't expec...
    By Chris B on The null check that didn't check for nulls
  • "It is also about as friendly as a monkey with a sore tooth and an alcohol addiction." And I have to clean my monitor.
    By Tim on When racing the Heisenbug, code quality goes out the Windows

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats
}