Click here to Skip to main content
15,889,860 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Pixar Pin
Ray Cassick16-Oct-09 6:56
Ray Cassick16-Oct-09 6:56 
AnswerRe: Pixar Pin
Tim Craig16-Oct-09 18:25
Tim Craig16-Oct-09 18:25 
AnswerRe: Pixar Pin
ely_bob27-Oct-09 7:09
professionalely_bob27-Oct-09 7:09 
AnswerRe: Pixar Pin
enhzflep29-Oct-09 10:11
enhzflep29-Oct-09 10:11 
GeneralRe: Pixar Pin
David Crow29-Oct-09 10:23
David Crow29-Oct-09 10:23 
QuestionComparison or travel algorithm for n-ary tree Pin
sampath_dr13-Oct-09 1:46
sampath_dr13-Oct-09 1:46 
AnswerRe: Comparison or travel algorithm for n-ary tree Pin
Henry Minute13-Oct-09 3:46
Henry Minute13-Oct-09 3:46 
QuestionConversion from double in java to decimal in C# on java [modified] Pin
ivica rangelov12-Oct-09 4:04
ivica rangelov12-Oct-09 4:04 
public void convertDoubleToDecimal(double value)
{
            long num = Double.doubleToLongBits(value);
            byte sign = (byte)((num & 0x8000000000000000L) >> 63);
            long exp = (num & 0x7ff0000000000000L) >> 52;
            int e = (int)exp - 1023;
            long fraction = num & 0x000fffffffffffffL;
            long valueBin = fraction | (1L << 52);
            int[] valueBinArray = new int[53];
            for (int i = 0; i < valueBinArray.length; i++)
                  valueBinArray[i] = (int)((valueBin & (long)Math.pow(2, i)) >> i);
            long intPart = 0;
            double fractionPart = 0;
            if (e <= 0)
            {
                  for (int i = e; i >= 0; i--)
                         intPart += valueBinArray[52 - (e - i)] * (int)Math.pow(2, i);
                  for (int i = -1; i >= -(52-e); i--)
                         fractionPart += valueBinArray[52 - (e - i)] * Math.pow(2, i);
            }
            else
            {
                  for (int i = 0; i &gt; -53; i--)
                         fractionPart += valueBinArray[i + 52] * Math.pow(2, i + e);
            }
            
            int decimalPlaces = 4;
            
            long number = (long)(intPart * Math.pow(10, decimalPlaces));
            number += (long)(fractionPart * Math.pow(10, decimalPlaces));
            byte[] buffer = new byte[16];
            //low
            buffer[0] = (byte)(number & 0x00000000000000ffL);
            buffer[1] = (byte)((number & 0x000000000000ff00L) >> 8);
            buffer[2] = (byte)((number & 0x0000000000ff0000L) >> 16);
            buffer[3] = (byte)((number & 0x00000000ff000000L) >> 24);
            //mid
            buffer[4] = (byte)((number & 0x000000ff00000000L) >> 32);
            buffer[5] = (byte)((number & 0x0000ff0000000000L) >> 40);
            buffer[6] = (byte)((number & 0x00ff000000000000L) >> 48);
            buffer[7] = (byte)((number & 0xff00000000000000L) >> 56);
            //high
            buffer[8] = (byte)0;
            buffer[9] = (byte)0;
            buffer[10] = (byte)0;
            buffer[11] = (byte)0;
            //flags
            buffer[12] = (byte)0;
            buffer[13] = (byte)0;
            buffer[14] = (byte)decimalPlaces;
            buffer[15] = sign;
}


modified on Monday, October 12, 2009 2:29 PM

AnswerRe: Conversion from double in java to decimal in C# on java Pin
Richard MacCutchan12-Oct-09 4:54
mveRichard MacCutchan12-Oct-09 4:54 
GeneralRe: Conversion from double in java to decimal in C# on java [modified] Pin
ivica rangelov12-Oct-09 8:43
ivica rangelov12-Oct-09 8:43 
GeneralRe: Conversion from double in java to decimal in C# on java Pin
Tim Craig12-Oct-09 20:53
Tim Craig12-Oct-09 20:53 
QuestionDetect A Circle In A Image Pin
allahmorad11-Oct-09 2:27
allahmorad11-Oct-09 2:27 
AnswerRe: Detect A Circle In A Image Pin
Tim Craig11-Oct-09 19:19
Tim Craig11-Oct-09 19:19 
AnswerRe: Detect A Circle In A Image Pin
Luc Pattyn12-Oct-09 0:22
sitebuilderLuc Pattyn12-Oct-09 0:22 
GeneralRe: Detect A Circle In A Image Pin
RichardM130-Oct-09 15:02
RichardM130-Oct-09 15:02 
QuestionOptimization problem with sets Pin
paradoxonok4-Oct-09 4:28
paradoxonok4-Oct-09 4:28 
AnswerRe: Optimization problem with sets Pin
Alan Balkany5-Oct-09 3:58
Alan Balkany5-Oct-09 3:58 
AnswerRe: Optimization problem with sets Pin
Paul Conrad8-Oct-09 16:46
professionalPaul Conrad8-Oct-09 16:46 
AnswerRe: Optimization problem with sets Pin
novice__geek30-Oct-09 0:06
novice__geek30-Oct-09 0:06 
QuestionPID for a Line Follower method ? Pin
Mohammad Dayyan28-Sep-09 17:11
Mohammad Dayyan28-Sep-09 17:11 
AnswerRe: PID for a Line Follower method ? Pin
Tim Craig29-Sep-09 10:04
Tim Craig29-Sep-09 10:04 
GeneralRe: PID for a Line Follower method ? Pin
Mohammad Dayyan29-Sep-09 12:22
Mohammad Dayyan29-Sep-09 12:22 
GeneralRe: PID for a Line Follower method ? Pin
Tim Craig29-Sep-09 18:27
Tim Craig29-Sep-09 18:27 
GeneralRe: PID for a Line Follower method ? Pin
Mohammad Dayyan30-Sep-09 1:09
Mohammad Dayyan30-Sep-09 1:09 
GeneralRe: PID for a Line Follower method ? Pin
Luc Pattyn30-Sep-09 2:28
sitebuilderLuc Pattyn30-Sep-09 2:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.