Click here to Skip to main content
16,009,598 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Control direction of rounding. Pin
Bassam Abdul-Baki25-Jan-07 5:39
professionalBassam Abdul-Baki25-Jan-07 5:39 
AnswerRe: Control direction of rounding. Pin
cmk1-Feb-07 10:49
cmk1-Feb-07 10:49 
QuestionWhen next putting a clock forward/back Pin
Hmarik24-Jan-07 23:21
Hmarik24-Jan-07 23:21 
AnswerRe: When next putting a clock forward/back Pin
Jeremy Falcon31-Jan-07 11:58
professionalJeremy Falcon31-Jan-07 11:58 
AnswerRe: When next putting a clock forward/back Pin
Luc Pattyn31-Jan-07 12:09
sitebuilderLuc Pattyn31-Jan-07 12:09 
GeneralRe: When next putting a clock forward/back Pin
Ingo12-Feb-07 12:34
Ingo12-Feb-07 12:34 
QuestionID3v2 tag size Pin
SilentBob10117-Jan-07 12:15
SilentBob10117-Jan-07 12:15 
AnswerRe: ID3v2 tag size Pin
AJR_UK17-Jan-07 15:08
AJR_UK17-Jan-07 15:08 
Expand the hex string 00 00 02 01 to binary, and you get 00000000 00000000 00000010 00000001. Now, we ignore the most significant bit (left-hand end of each byte) giving the bit string 0000000 0000000 0000010 0000001, which when read as normal 8-bit bytes and padded to fill the top byte (padding in brackets) is (0000)0000 00000000 00000001 00000001, or hex 00 00 01 01 which is, in decimal, 257.

This following is a C function to get the size of the tag (assumes int is 32 bits and char is 8 bits.) The first of the four bytes from the ID3 tag is placed in the first position in the array, so for the example input, encodedSize[0] = 0x0, encodedSize[1] = 0x0, encodedSize[2] = 0x2, encodedSize[3] = 0x1.)
int getTagSize(char encodedSize[4])
{
  int retval = 0;

  retval = encodedSize[0] << 21 | encodedSize[1] << 14 | encodedSize[2] << 7 | encodedSize[3];

  return retval;
}

Not that this function doesn't do any form of sanity check on the input data, which is a Bad Thing™ in real code you must check that each byte of the encoded size is < 0x80, and do whatever is appropriate in your app when encountering an invalid ID3 tag if the test fails.

As for the aside about maximum tag size, the max value with this encoding is $7f 7f 7f 7f, which represents 268435455 bytes, or 256 MB, of ID3v2 tag. I don't see where you're getting 4*127*127 from, but the reason why 127*127*127*127 = 260144641 is wrong is that, while the maximum value for each byte is 127, the total number of values for each byte is 128, and so there are 128*128*128*128 = 268435456 possible values for the tag size (0-268435455)
GeneralRe: ID3v2 tag size Pin
SilentBob10118-Jan-07 1:24
SilentBob10118-Jan-07 1:24 
GeneralGotta Love Twins Pin
Bassam Abdul-Baki15-Jan-07 12:42
professionalBassam Abdul-Baki15-Jan-07 12:42 
GeneralRe: Gotta Love Twins Pin
Russell Jones15-Jan-07 23:07
Russell Jones15-Jan-07 23:07 
GeneralRe: Gotta Love Twins Pin
Bassam Abdul-Baki16-Jan-07 3:12
professionalBassam Abdul-Baki16-Jan-07 3:12 
GeneralRe: Gotta Love Twins Pin
Sauce!19-Jan-07 0:33
Sauce!19-Jan-07 0:33 
GeneralRe: Gotta Love Twins Pin
Rob Graham19-Jan-07 3:13
Rob Graham19-Jan-07 3:13 
GeneralRe: Gotta Love Twins Pin
Nathan Addy29-Jan-07 12:37
Nathan Addy29-Jan-07 12:37 
QuestionScoring a number of values/weightings and normalizing Pin
Subterranean14-Jan-07 4:54
Subterranean14-Jan-07 4:54 
AnswerRe: Scoring a number of values/weightings and normalizing Pin
CPallini16-Jan-07 9:53
mveCPallini16-Jan-07 9:53 
QuestionLicense plate recognsition in c++ Pin
mchaudhary13-Jan-07 12:27
mchaudhary13-Jan-07 12:27 
AnswerRe: License plate recognsition in c++ Pin
Luc Pattyn13-Jan-07 18:53
sitebuilderLuc Pattyn13-Jan-07 18:53 
Questioncalculate the sun-up Pin
daniel9912-Jan-07 22:19
daniel9912-Jan-07 22:19 
AnswerRe: calculate the sun-up Pin
Sauce!13-Jan-07 1:58
Sauce!13-Jan-07 1:58 
GeneralRe: calculate the sun-up Pin
daniel9913-Jan-07 4:31
daniel9913-Jan-07 4:31 
GeneralRe: calculate the sun-up [modified] Pin
CoffeeAddict1913-Jan-07 5:40
CoffeeAddict1913-Jan-07 5:40 
AnswerRe: calculate the sun-up Pin
El Corazon13-Jan-07 9:40
El Corazon13-Jan-07 9:40 
QuestionPathFinding algorithm Pin
Waldermort12-Jan-07 8:13
Waldermort12-Jan-07 8:13 

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.