Click here to Skip to main content
15,919,749 members
Home / Discussions / C#
   

C#

 
QuestionFree easy to use CHM editor? Pin
Member 391904916-May-08 9:11
Member 391904916-May-08 9:11 
AnswerRe: Free easy to use CHM editor? Pin
Thomas Stockwell16-May-08 10:33
professionalThomas Stockwell16-May-08 10:33 
GeneralRe: Free easy to use CHM editor? Pin
Member 391904916-May-08 11:25
Member 391904916-May-08 11:25 
GeneralRe: Free easy to use CHM editor? Pin
Thomas Stockwell16-May-08 11:45
professionalThomas Stockwell16-May-08 11:45 
QuestionConcat two integers without cast Pin
mik116-May-08 7:03
mik116-May-08 7:03 
AnswerRe: Concat two integers without cast [modified] Pin
darkelv16-May-08 7:22
darkelv16-May-08 7:22 
GeneralRe: Concat two integers without cast Pin
Mustafa Ismail Mustafa16-May-08 7:33
Mustafa Ismail Mustafa16-May-08 7:33 
AnswerRe: Concat two integers without cast [modified] Pin
User 665816-May-08 7:58
User 665816-May-08 7:58 
I think it should be possible with some bitshifting, but this is a simple solution:

public int ConcatInts(int x, int y)
{
    return (x * ((int)Math.Pow(10, NumDecs(y)))) + y;
}

public int NumDecs(int x)
{
    int result = 1;
    while (x >= 10)
    {
        x /= 10;
        result++;
    }

    return result;
}


or, by using the logarithm with base 10:

public int ConcatInts(int x, int y)
{
   return x * (int)(Math.Pow(10, (int)Math.Log10(y)+1)) + y;
}


Some time comparisons, with the string method being the slowest (100%, but might be optimized a bit using a StringBuilder):

Log: 31,62%
Loop: 30,57%

for 100000000 runs each.

regards

modified on Friday, May 16, 2008 2:15 PM


modified 12-Sep-18 21:01pm.

AnswerRe: Concat two integers without cast Pin
Guffa16-May-08 8:24
Guffa16-May-08 8:24 
AnswerRe: Concat two integers without cast Pin
PIEBALDconsult16-May-08 10:25
mvePIEBALDconsult16-May-08 10:25 
Questionwhich c# encoding is windows-1252 Pin
stephan_00716-May-08 6:10
stephan_00716-May-08 6:10 
AnswerRe: which c# encoding is windows-1252 Pin
Alan N16-May-08 6:57
Alan N16-May-08 6:57 
QuestionHow to know available memory? Pin
s196675m16-May-08 4:48
s196675m16-May-08 4:48 
AnswerRe: How to know available memory? Pin
PIEBALDconsult16-May-08 5:36
mvePIEBALDconsult16-May-08 5:36 
AnswerRe: How to know available memory? Pin
Ennis Ray Lynch, Jr.16-May-08 5:50
Ennis Ray Lynch, Jr.16-May-08 5:50 
GeneralRe: How to know available memory? Pin
s196675m16-May-08 10:00
s196675m16-May-08 10:00 
GeneralRe: How to know available memory? Pin
PIEBALDconsult16-May-08 10:26
mvePIEBALDconsult16-May-08 10:26 
GeneralRe: How to know available memory? Pin
s196675m16-May-08 10:44
s196675m16-May-08 10:44 
GeneralRe: How to know available memory? [modified] Pin
PIEBALDconsult16-May-08 11:21
mvePIEBALDconsult16-May-08 11:21 
GeneralRe: How to know available memory? Pin
s196675m16-May-08 17:13
s196675m16-May-08 17:13 
GeneralRe: How to know available memory? Pin
PIEBALDconsult16-May-08 18:29
mvePIEBALDconsult16-May-08 18:29 
AnswerRe: How to know available memory? Pin
The Nightcoder16-May-08 22:56
The Nightcoder16-May-08 22:56 
AnswerRe: How to know available memory? Pin
#realJSOP17-May-08 2:30
professional#realJSOP17-May-08 2:30 
QuestionQuickbase UI Pin
RobPettipasX1116-May-08 4:41
RobPettipasX1116-May-08 4:41 
AnswerRe: Quickbase UI Pin
led mike16-May-08 4:55
led mike16-May-08 4:55 

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.