1

Topic: Aplikasi convert decimal - binary

Halooo semuaaa.. mohon pertolongannya yah..
ada yang tau gak buat aplikasi di delphi,
aplikasi yang bisa convert decimal ke biner, n sebaliknya biner ke decimal??
mohon share yahh..
perlu banget nih..
thanks wink

2

Re: Aplikasi convert decimal - binary

Logic untuk converting Binary to Decimal dan Decimal To Binary sebagai berikut :
Tidak paham Delphi, tapi logikanya sih sebagai berikut:

                // Binary to Decimal
                private void BinToDec()
        {        
            int dec = 0;
            string strBin = "1100";
            for(int i=0;i<strBin.Length;i++)
            {            
                if(strBin[i]=='1')
                    dec+= Convert.ToInt32(Math.Pow(2,strBin.Length - 1 - i));
            }
            Console.Write(dec.ToString());
        }        


                // Decimal to Binary 
        private void DecToBin()
        {
            int dec = 13;
            int temp = 0;
            string varBinary = cek(dec);
            temp = dec/2;
            while(temp!=0 && temp!=1)
            {
                varBinary = cek(temp)+varBinary;
                temp = temp / 2;                
            }
            varBinary = temp + varBinary;
            Console.Write(varBinary);
        }
        private string cek(int a)
        {
            if(a%2==0)
                return "0";
            else
                return "1";
        }

Have a try ^^

Last edited by JN (2010-08-18 12:09:51)

3

Re: Aplikasi convert decimal - binary

Hmm, saya ngga ngerti bahasa Delphi (kalo Devi saya kenal)... Hehehe, tapi saya ngerti dalam C++, saya coba post dalam C++ yah karena saya liat Mas JN pake C# yang lebih udah advanced, nanti coba dikonversi sendiri ajah ^^

Konversi Decimal ke Biner
Ilustrasi konversi:

Konversi 13d ke biner:
Bagi 13 dengan 2. Sisa hasil pembagian ditampung dalam sebuah string. Hasil pembagian dibagi lagi dengan 2, sampai hasil baginya = 1. Sisa hasil pembagian yang ditampung dalam string dibalikkan = Hasil konversi dalam biner.

  13
1---2
   6 -> hasil
0---2
   3 -> hasil
1---2
   1 -> hasil

Hasil konversi dalam biner (dalam bold, dibalik): 1101
Contoh code:

#include "stdio.h"
#include "string.h"

int main()
{
    int i,n,a;
    char s[100];

    //decimal -> biner
    printf("Insert decimal: ");
    scanf("%d", &a);
    
    for(n=0,i=a; i>=1; i/=2)
    {
        s[n++] = (i%2) + '0';
    }
    s[n] = '\0';

    n = strlen(s) - 1;
    //balikkan angka hasil pembagian
    for(i=n; i>=0; i--)
    {
        printf("%c", s[i]);
    }

    printf("\n");
    
    return 0;
}

Konversi Biner ke Decimal
Ilustrasi konversi:

Konversi 1101 ke decimal:
Digit terakhir * 2^0 + digit kedua terakhir * 2^1 + digit ketiga terakhir * 2^2 + digit keempat terakhir * 2^3 + dst... Simple kan ^^

1101 = (1 * 2^0) + (0 * 2^1) + (1 * 2^2) + (1 * 2^3)
= 1 + 0 + 4 + 8
= 13


Contoh code:

#include "stdio.h"
#include "string.h"
#include "math.h"

int main()
{
    int i,n,a;
    char s[100];

    //Biner -> decimal
    printf("Insert Binary: ");
    scanf("%s", s);

    n = strlen(s) - 1;
    a = 0;
    for(i=n; i>=0; i--)
    {
        a += (s[i] - '0') * pow(2, n-i);
    }
    printf("%d\n", a);

    return 0;
}

Semoga membantu smile

Last edited by StevenLuck (2010-08-18 16:18:26)

4

Re: Aplikasi convert decimal - binary

Why Netflix Should Be An $82 Stock| Netflix is a movie rental company that makes film and TV programming available to customers via mailed DVDs and online streaming  all for a fixed monthly subscription. In the expectation that online viewing will dominate the video market in future  Netflix is currently expanding its online catalog. On the other hand  cable providers like Comcast are fighting to keep their subscribers by building video-on-demand services to stem subscriber losses. Below we compare Netflix and Comcast in terms of their current offerings and strategic outlook. Our conclusion: While Netflix is currently in a strong position versus its cable competitors  the cable industry could benefit from inherent flaws in Netflix’s subscription pricing model. What favors cable providers like Comcast? 1) Content owners demand maximum profits Declining DVD sales and piracy are eating away potential revenues and profits for content owners jaeger lecoultre replica   who must now find other ways to make money. One good example is Disney and Fox’s battle with Dish Network over carriage fee increments. And several studios recently introduced a 28-day delay in making programming available for rental. Compared to rental distributors like Netflix  content owners can generally reap higher profits from cable providers replica chronoswiss tora dual time watch   with their bulk carriage capacity and higher on-demand pricing. 2) Comcast has good studio relationships and enormous buying power  Comcast and other cable providers have been distributing video content over their networks for a very long time and have established strong ties with studios. They can use these relationships to acquire on-demand rights to more content. And Comcast has deep pockets. If it’s willing to pay more for the video-on-demand content that it acquires  it might influence content owners to provide exclusive distribution rights  albeit for a short period of time. Are you ready for earnings season? Larry McMillan’s subscribers doubled their money in options on Ctrip.com (CTRP) and United Airline’s parent UAL Corp. (UAUA). Click here for today’s and tomorrow’s trades in Larry McMillan’s Daily Volume Alerts…try it with a money-back Forbes guarantee. What favors Netflix? 1) Netflix’s pricing is much more attractive than Comcast’s A Netflix subscription of $8.99 per month allows customers to rent one DVD at a time and gives them unlimited access to movie and TV downloads. If we assume that a typical customer watches two movies each weekend  the $8.99 plan yields an average cost of $1.12 per movie. On the other hand  Comcast charges $5 to $6 per movie for on-demand viewing of more recent releases. Many consumers seem willing to wait until the Comcast sell-through window passes to order the DVD version from Netflix. Although Comcast does offer some older movies for free swiss burberry watch   its catalogue is currently less rich than that of Netflix. 2) Customers like a mix of older and newer releases  Netflix provides both older and newer movies and TV shows on DVD. Although Netflix has agreements in place with several studios to delay making newer releases available for rental for 28 days  most customers are willing to wait that long. Moreover replica montblanc profile   Netflix’s online content is skewed toward older movies and TV shows  and is available to its subscribers for instant streaming at no additional cost. So far replica watches   customers seem content with Netflix’s product mix. Can Netflix sustain its low prices? As more customers resist Comcast’s on-demand pricing  the company may need to adopt a subscription-based model similar to that of Netflix. That said  the subscription model is not the best way for content owners to maximize their profits. In exchange for the 28-day delay in renting new releases  Netflix is able to acquire online content at cheap prices  which it passes on to its customers. But will Netflix be able to sustain its low cost of content acquisition in the long term? Mark Cuban  an entrepreneur  has argued that Netflix can’t sustain its low cost base for acquiring content because content owners are likely to demand higher profits. In this situation  Netflix would pass higher acquisition costs on to its customers and lose its competitive edge over cable providers. Below you can see how Netflix’s stock could be impacted by changes in its average subscription price.    Bottom line: Cable providers like Comcast could benefit from a scenario in which Netflix is forced to raise its subscription price. You can see the complete $82.26 Trefis price estimate for Netflix’s stock here                                                                                                                   0 comments  0 called-out

5

Re: Aplikasi convert decimal - binary

hole. Pirate Costume  Karen Lunn stated that playing with Karrie Webb was the highlight of her profession and their pairing was just incredible. She also helped her a great deal in gaining the self-confidence for the match and that's what helped her out all through final year's match superhero Costume . It's challenging to possess that type of bond having a player but whenever you type 1 you realize it'll assist you to a great deal within the game halloween costume . The tournament will probably be getting 72 holes, 36 of them will probably be in Fourball much better ball format and also the rest from the 36 holes will probably be inside a variation of foursome format exactly where on par 4 each the players hit tee shots after which players will play the shot that her companion has placed for them within the

6

Re: Aplikasi convert decimal - binary

sangat sulit sekali untuk membuat aplikasi delphi