Click here to Skip to main content
14,176,272 members
   

Delphi

 
AnswerRe: New To Delphi - Want a Right Direction Pin
smags136-May-12 21:54
membersmags136-May-12 21:54 
AnswerRe: New To Delphi - Want a Right Direction Pin
Eddy Vluggen22-May-12 9:57
mveEddy Vluggen22-May-12 9:57 
AnswerRe: New To Delphi - Want a Right Direction Pin
nortee28-May-12 10:02
membernortee28-May-12 10:02 
AnswerRe: New To Delphi - Want a Right Direction Pin
Amarnath S3-Jun-12 21:56
professionalAmarnath S3-Jun-12 21:56 
AnswerRe: New To Delphi - Want a Right Direction Pin
smags136-Jun-12 8:53
membersmags136-Jun-12 8:53 
QuestionDelphi to C# Pin
coert dorrepaal24-Apr-12 1:52
membercoert dorrepaal24-Apr-12 1:52 
AnswerRe: Delphi to C# Pin
Richard MacCutchan24-Apr-12 2:50
protectorRichard MacCutchan24-Apr-12 2:50 
AnswerRe: Delphi to C# Pin
smags1324-Apr-12 10:38
membersmags1324-Apr-12 10:38 
Ha, I wouldn't grab your thought if I didn't come across your post in Quick Answer section. Please edit your post here so that other people would understand.

Ok, first the function might have overflow issue, depending on the logic, and it is not exception safe, leading to unexpected results. But it's nothing to do with your question, so I will pass this part.

I assume
1. TByteDynArray is array of Byte. if it's not, the following might be useless. Sigh | :sigh:

2. and endian representation is the same on all machines where your codes will run.

double BufToDataBin(byte[] Buf, int iStartPos, int iLen, int iDec)
{
  const int DefaultLen = 8;
  double fTmp = 0;
  Int64 iTmp = 0;
  try
  {
    byte[] arr = { 0, 0, 0, 0, 0, 0, 0, 0 };
    if ((Buf[iStartPos] & 0x80) == 0x80 && !IsCardinal)//IsCardinal??
    {
      if (Negative)//Negative??
      {
        for (int i = 0; i <= iLen - 2; ++i)
        {
          arr[i] = (byte)(Buf[iStartPos + iLen - 1 - i] ^ 0xFF);
        }
        iTmp = BitConverter.ToInt64(arr, 0);
      }
      else
      {
        for (int i = 0; i <= iLen - 2; ++i)
        {
          arr[i] = (byte)(Buf[iStartPos+iLen-1-i]);
        }
        iTmp = BitConverter.ToInt64(arr, 0);
      }
      fTmp = 0 - iTmp / Math.Pow(10, iDec);

    }
    else
    {
      for (int i = 0; i < iLen; ++i)
      {
        arr[i] = Buf[iStartPos+iLen-1-i];
      }
      iTmp = BitConverter.ToInt64(arr, 0);
      fTmp = iTmp / Math.Pow(10, iDec);    
    }
  }
  catch
  {
    //do something
  }
  return fTmp;
}


Further optimization might be requested.
Questioncomunication Pin
harry88 20125-Apr-12 1:29
memberharry88 20125-Apr-12 1:29 
AnswerRe: comunication Pin
smags1311-Apr-12 12:06
membersmags1311-Apr-12 12:06 
Questiondeclaring math function Pin
Saeed_Ansari30-Mar-12 4:34
memberSaeed_Ansari30-Mar-12 4:34 
AnswerRe: declaring math function Pin
smags1330-Mar-12 12:47
membersmags1330-Mar-12 12:47 
AnswerRe: declaring math function Pin
Stuart Cox from Victoria31-Mar-12 10:04
memberStuart Cox from Victoria31-Mar-12 10:04 
QuestionDelphi 2007 not compiling runtimes into exe Pin
JerryMallett6-Mar-12 22:34
memberJerryMallett6-Mar-12 22:34 
AnswerRe: Delphi 2007 not compiling runtimes into exe Pin
nortee8-Mar-12 0:48
membernortee8-Mar-12 0:48 
GeneralRe: Delphi 2007 not compiling runtimes into exe Pin
JerryMallett8-Mar-12 0:56
memberJerryMallett8-Mar-12 0:56 
GeneralRe: Delphi 2007 not compiling runtimes into exe Pin
smags138-Mar-12 14:17
membersmags138-Mar-12 14:17 
GeneralRe: Delphi 2007 not compiling runtimes into exe Pin
JerryMallett8-Mar-12 23:10
memberJerryMallett8-Mar-12 23:10 
GeneralRe: Delphi 2007 not compiling runtimes into exe Pin
smags139-Mar-12 10:30
membersmags139-Mar-12 10:30 
GeneralRe: Delphi 2007 not compiling runtimes into exe Pin
nortee9-Mar-12 11:34
membernortee9-Mar-12 11:34 
NewsDelphi online birthday party ?! Pin
smags137-Feb-12 7:54
membersmags137-Feb-12 7:54 
GeneralRe: Delphi online birthday party ?! Pin
nortee7-Feb-12 8:28
membernortee7-Feb-12 8:28 
GeneralRe: Delphi online birthday party ?! Pin
smags1329-Feb-12 8:39
membersmags1329-Feb-12 8:39 
QuestionCan TWebModule instance shutdown itself? Pin
Corinna John31-Jan-12 4:17
memberCorinna John31-Jan-12 4:17 
GeneralRe: Can TWebModule instance shutdown itself? Pin
smags1331-Jan-12 8:10
membersmags1331-Jan-12 8:10 

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.


Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190525.1 | Last Updated 25 Apr 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid