LinqToSimpleDB Forum Rss Feedhttp://www.codeplex.com/LinqToSimpleDB/Thread/List.aspxLinqToSimpleDB Forum Rss DescriptionNew Post: Integer handlinghttp://linqtosimpledb.codeplex.com/Thread/View.aspx?ThreadId=25754<div style="line-height: normal;"><p>Hi Justin,</p>
<p>I also read your post on data-type conversions with SimpleDB (<a title="http://www.codethinked.com/post/2007/12/31/Linq-To-SimpleDB-Issues.aspx" href="http://www.codethinked.com/post/2007/12/31/Linq-To-SimpleDB-Issues.aspx">http://www.codethinked.com/post/2007/12/31/Linq-To-SimpleDB-Issues.aspx</a>).</p>
<p>You may be interested in checking my approach to this for <a href="http://simplesavant.codeplex.com">http://simplesavant.codeplex.com</a>. Nice job on this library, by the way.</p>
<p>Regards,</p>
<p>Ashley</p>
<p> </p>
<p> </p></div>ashleytateThu, 25 Jun 2009 18:27:08 GMTNew Post: Integer handling 20090625062708PNEW POST: Integer handlinghttp://www.codeplex.com/LinqToSimpleDB/Thread/View.aspx?ThreadId=25754<div class="wikidoc">
Hi <br /> <br />I saw your blog post on Linq, SimpleDB and integers. <br /> <br />It got me thinking and there seem to be two problems (sorry if you already handled these cases):<br /> <br />1. Zero-padding to ensure lexicographical comparision. That is fairly easy and the number of paddings you need should be easy to extract from the datatype in use. E.g. Int32 will need 10 digits at the most (11 for sign). <br />It might be an idea to store the numbers in the hex equivalents as you would need a lot less digits then. <br /> <br />2. Negative numbers.<br />What you want is to be able to query for numbers and have < and > work properly. <br />I see two solutions for this:<br /> <br />2a) If you are working with signed Int32 then begin to work with unsigned Int32 instead, and the number you add should be uint32.Max/2, then you can handle everything that int32 can handle. Same scheme will work for decimals, etc.<br /> <br />2b) If you "encode" your numbers this way, everything should work as expected, but you of course need to handle the encoding/decoding automatically.<br />First, pad all positive numbers as before, but add an extra "0"<br />Second, negative numbers have one less padding - instead they start with "-"<br />Third, the digits in the negative number are reversed, so the padding actually is to the right of the number.<br />Example:<br />(4+1 digit for clarity)<br /> <br />1 = 00001<br />20 = 00020<br /> <br />-1 = -1000<br />-20= -0200<br /> <br />Please note that "-" has a lower ascii number than "0", so you should add an extra "0" to the positive numbers.<br /> <br />Either way could handle your integer problem. What to choose? Your choice.<br />
</div>SoerenNielsenFri, 11 Apr 2008 07:23:50 GMTNEW POST: Integer handling 20080411072350A