Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# code to triple a number

C# code to triple a number

Scheduled Pinned Locked Moved C#
csharpmcp
18 Posts 11 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Oluwayomi

    I need a code snippet to triple numbers.

    Oluwayomi Ige MCP MCAD

    J Offline
    J Offline
    J4amieC
    wrote on last edited by
    #2

    Seriously?? no. you have got tobe kidding? right? please...? :omg:

    C 1 Reply Last reply
    0
    • O Oluwayomi

      I need a code snippet to triple numbers.

      Oluwayomi Ige MCP MCAD

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #3

      Oluwayomi wrote:

      I need a code snippet to triple numbers.

      Oluwayomi wrote:

      MCP MCAD

      And people ask me why I don't value certifications.....

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      D 1 Reply Last reply
      0
      • J J4amieC

        Seriously?? no. you have got tobe kidding? right? please...? :omg:

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #4

        Did you notice he's Microsoft certified ?

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        X 1 Reply Last reply
        0
        • O Oluwayomi

          I need a code snippet to triple numbers.

          Oluwayomi Ige MCP MCAD

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #5

          OK then. Here's a choice for you:

          public int Triple(int value)
          {
          //...put your implementation here.
          }
          public long Triple(long value)
          {
          //...put your implementation here.
          }

          .. and so on. Obviously you'll want to implement exception handling and validation to take care of those cases where the return values are outside min/max values. To call them you would do:

          int value = Triple(10);

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          1 Reply Last reply
          0
          • C Christian Graus

            Oluwayomi wrote:

            I need a code snippet to triple numbers.

            Oluwayomi wrote:

            MCP MCAD

            And people ask me why I don't value certifications.....

            Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            D Offline
            D Offline
            dan sh
            wrote on last edited by
            #6

            here you go: . . . number anyNumber; console.writeline("Computer...triple the number above or i will shoot"); . . . .

            My idea of ideal life : Eat, Sleep, Repeat

            1 Reply Last reply
            0
            • C Christian Graus

              Did you notice he's Microsoft certified ?

              Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              X Offline
              X Offline
              Xmen Real
              wrote on last edited by
              #7

              nevermind he was checking us...xD

              TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can

              1 Reply Last reply
              0
              • O Oluwayomi

                I need a code snippet to triple numbers.

                Oluwayomi Ige MCP MCAD

                realJSOPR Offline
                realJSOPR Offline
                realJSOP
                wrote on last edited by
                #8

                When you say "triple", do you mean: 1) Multiply it by 3 2) Multiply it by itself 3 times 3) Display it three times like "101010" 4) Chop off your neighbor's head and put it on a pike in your front yard 5) Post a programming question in the Lounge 6) Herd elephants to their doom 7) Offer a starving muslim a pork sandwich

                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                -----
                "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                1 Reply Last reply
                0
                • O Oluwayomi

                  I need a code snippet to triple numbers.

                  Oluwayomi Ige MCP MCAD

                  B Offline
                  B Offline
                  BadKarma
                  wrote on last edited by
                  #9

                  Hi, You can use the following classes

                  public class Single
                  {
                    private int _iValue;
                  
                    public int Value
                    {
                      get { return _iValue; }
                    }
                  
                    public Single() : this(0) {}
                    public Single(int iValue) 
                    {
                      _iValue = iValue;
                    }
                  };
                  
                  public class Double
                  {
                    private int _iValue;
                  
                    public int Value
                    {
                      get 
                      {
                        Single sinA = new Single(_iValue);
                        Single sinB = new Single(_iValue);
                        
                        return sinA.Value + sinB.Value; 
                      }
                    }
                  
                    public Double() : this(0) {}
                    public Double(int iValue) 
                    {
                      _iValue = iValue;
                    }
                  };
                  
                  public class Tripple
                  {
                    private int _iValue;
                  
                    public int Value
                    {
                      get
                      {
                        Double douA = new Double(_iValue);
                        Single sinB = new Single(_iValue);
                  
                        return douA.Value + sinB.Value;
                      }
                    }
                  
                    public Tripple() : this(0) { }
                    public Tripple(int iValue)
                    {
                      _iValue = iValue;
                    }
                  };
                  

                  You can use it like this;

                  Tripple tripNumber = new Tripple(5);
                  int iData = tripNumber.Value;
                  

                  Learn from the mistakes of others, you may not live long enough to make them all yourself.

                  J 1 Reply Last reply
                  0
                  • B BadKarma

                    Hi, You can use the following classes

                    public class Single
                    {
                      private int _iValue;
                    
                      public int Value
                      {
                        get { return _iValue; }
                      }
                    
                      public Single() : this(0) {}
                      public Single(int iValue) 
                      {
                        _iValue = iValue;
                      }
                    };
                    
                    public class Double
                    {
                      private int _iValue;
                    
                      public int Value
                      {
                        get 
                        {
                          Single sinA = new Single(_iValue);
                          Single sinB = new Single(_iValue);
                          
                          return sinA.Value + sinB.Value; 
                        }
                      }
                    
                      public Double() : this(0) {}
                      public Double(int iValue) 
                      {
                        _iValue = iValue;
                      }
                    };
                    
                    public class Tripple
                    {
                      private int _iValue;
                    
                      public int Value
                      {
                        get
                        {
                          Double douA = new Double(_iValue);
                          Single sinB = new Single(_iValue);
                    
                          return douA.Value + sinB.Value;
                        }
                      }
                    
                      public Tripple() : this(0) { }
                      public Tripple(int iValue)
                      {
                        _iValue = iValue;
                      }
                    };
                    

                    You can use it like this;

                    Tripple tripNumber = new Tripple(5);
                    int iData = tripNumber.Value;
                    

                    Learn from the mistakes of others, you may not live long enough to make them all yourself.

                    J Offline
                    J Offline
                    J4amieC
                    wrote on last edited by
                    #10

                    Great answer, but you have too much time on your hands! :laugh:

                    B 1 Reply Last reply
                    0
                    • O Oluwayomi

                      I need a code snippet to triple numbers.

                      Oluwayomi Ige MCP MCAD

                      C Offline
                      C Offline
                      CPallini
                      wrote on last edited by
                      #11

                      What about http://www.careerchange.com/[^]? :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                      1 Reply Last reply
                      0
                      • J J4amieC

                        Great answer, but you have too much time on your hands! :laugh:

                        B Offline
                        B Offline
                        BadKarma
                        wrote on last edited by
                        #12

                        J4amieC wrote:

                        Great answer, but you have too much time on your hands!

                        This is not correct. If I would have too much time on my hands I would have come with something Generic like this:

                        // Making it generic
                        MultiType<Double, Double> mul4 = new MultiType<Double, Double>(5);
                        int iData = mul4.Value;
                        
                        MultiType<Double, MultiType<Double, Single>> mul5 = new MultiType<Double, MultiType<Double, Single>>(5);
                        iData = mul5.Value;
                        

                        And the classes:

                        public class Single 
                        {
                          protected int _iValue;
                        
                          public int Value
                          {
                            get { return Data(); }
                          }
                        
                          public void setValue(int IValue)
                          {
                            _iValue = IValue;
                          }
                        
                          protected virtual int Data()
                          {
                            return _iValue;
                          }
                        
                          public Single() : this(0) {}
                          public Single(int iValue) 
                          {
                            _iValue = iValue;
                          }
                        };
                        
                        public class Null : Single
                        {
                          public Null() : this(0) { }
                          public Null(int iValue)
                          {
                            _iValue = 0;
                          }
                        
                          protected override int Data()
                          {
                            return 0;
                          }
                        };
                        
                        public class Double : Single
                        {
                          protected override int Data()
                          {
                            Single sinA = new Single(_iValue);
                            Single sinB = new Single(_iValue);
                            
                            return sinA.Value + sinB.Value;
                          }
                        
                          public Double() : this(0) {}
                          public Double(int iValue) 
                          {
                            _iValue = iValue;
                          }
                        };
                        
                        public class MultiType<TL, TR> : Single
                          where TL : Single, new()
                          where TR : Single, new()  
                        {
                          public MultiType() : this(0) { }
                          public MultiType(int iValue)
                          { 
                            _iValue = iValue;
                          }
                        
                           protected override int Data()
                           {
                             Single baseLeft = new TL();
                             baseLeft.setValue(_iValue);
                        
                             Single baseRight = new TR();
                             baseRight.setValue(_iValue);
                        
                             return baseLeft.Value + baseRight.Value;
                           }
                        };
                        

                        Learn from the mistakes of others, you may not live long enough to make them all yourself.

                        J 1 Reply Last reply
                        0
                        • O Oluwayomi

                          I need a code snippet to triple numbers.

                          Oluwayomi Ige MCP MCAD

                          O Offline
                          O Offline
                          Osten
                          wrote on last edited by
                          #13

                          I myself made an assembly (TripleMachine.dll) that I just import whenever I need to triple a number. It has support for multithreading, for when I need to tripple large chunks of data.

                          boolean dontNotCancel = ((!false && true) != (!true || false)) ? ((false == false || (true && (false == true ? true : false))) ? true : false) : (true != false && false);

                          L 1 Reply Last reply
                          0
                          • O Osten

                            I myself made an assembly (TripleMachine.dll) that I just import whenever I need to triple a number. It has support for multithreading, for when I need to tripple large chunks of data.

                            boolean dontNotCancel = ((!false && true) != (!true || false)) ? ((false == false || (true && (false == true ? true : false))) ? true : false) : (true != false && false);

                            L Offline
                            L Offline
                            laserbaronen
                            wrote on last edited by
                            #14

                            hey, looks like my signature o.o


                            betonglasermur.FeedDwarf(pur_is, 17);
                            ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);

                            Morgonen är tröttmans mecka

                            O 1 Reply Last reply
                            0
                            • L laserbaronen

                              hey, looks like my signature o.o


                              betonglasermur.FeedDwarf(pur_is, 17);
                              ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);

                              Morgonen är tröttmans mecka

                              O Offline
                              O Offline
                              Osten
                              wrote on last edited by
                              #15

                              hey, that does not look like it isn't my signature

                              boolean dontNotCancel = ((!false && true) != (!true || false)) ? ((false == false || (true && (false == true ? true : false))) ? true : false) : (true != false && false);

                              L 1 Reply Last reply
                              0
                              • O Osten

                                hey, that does not look like it isn't my signature

                                boolean dontNotCancel = ((!false && true) != (!true || false)) ? ((false == false || (true && (false == true ? true : false))) ? true : false) : (true != false && false);

                                L Offline
                                L Offline
                                laserbaronen
                                wrote on last edited by
                                #16

                                hey, that aint not no signature :confused::confused::confused:


                                betonglasermur.FeedDwarf(pur_is, 17);
                                ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);

                                Morgonen är tröttmans mecka

                                1 Reply Last reply
                                0
                                • B BadKarma

                                  J4amieC wrote:

                                  Great answer, but you have too much time on your hands!

                                  This is not correct. If I would have too much time on my hands I would have come with something Generic like this:

                                  // Making it generic
                                  MultiType<Double, Double> mul4 = new MultiType<Double, Double>(5);
                                  int iData = mul4.Value;
                                  
                                  MultiType<Double, MultiType<Double, Single>> mul5 = new MultiType<Double, MultiType<Double, Single>>(5);
                                  iData = mul5.Value;
                                  

                                  And the classes:

                                  public class Single 
                                  {
                                    protected int _iValue;
                                  
                                    public int Value
                                    {
                                      get { return Data(); }
                                    }
                                  
                                    public void setValue(int IValue)
                                    {
                                      _iValue = IValue;
                                    }
                                  
                                    protected virtual int Data()
                                    {
                                      return _iValue;
                                    }
                                  
                                    public Single() : this(0) {}
                                    public Single(int iValue) 
                                    {
                                      _iValue = iValue;
                                    }
                                  };
                                  
                                  public class Null : Single
                                  {
                                    public Null() : this(0) { }
                                    public Null(int iValue)
                                    {
                                      _iValue = 0;
                                    }
                                  
                                    protected override int Data()
                                    {
                                      return 0;
                                    }
                                  };
                                  
                                  public class Double : Single
                                  {
                                    protected override int Data()
                                    {
                                      Single sinA = new Single(_iValue);
                                      Single sinB = new Single(_iValue);
                                      
                                      return sinA.Value + sinB.Value;
                                    }
                                  
                                    public Double() : this(0) {}
                                    public Double(int iValue) 
                                    {
                                      _iValue = iValue;
                                    }
                                  };
                                  
                                  public class MultiType<TL, TR> : Single
                                    where TL : Single, new()
                                    where TR : Single, new()  
                                  {
                                    public MultiType() : this(0) { }
                                    public MultiType(int iValue)
                                    { 
                                      _iValue = iValue;
                                    }
                                  
                                     protected override int Data()
                                     {
                                       Single baseLeft = new TL();
                                       baseLeft.setValue(_iValue);
                                  
                                       Single baseRight = new TR();
                                       baseRight.setValue(_iValue);
                                  
                                       return baseLeft.Value + baseRight.Value;
                                     }
                                  };
                                  

                                  Learn from the mistakes of others, you may not live long enough to make them all yourself.

                                  J Offline
                                  J Offline
                                  J4amieC
                                  wrote on last edited by
                                  #17

                                  You sir are a genius!

                                  B 1 Reply Last reply
                                  0
                                  • J J4amieC

                                    You sir are a genius!

                                    B Offline
                                    B Offline
                                    BadKarma
                                    wrote on last edited by
                                    #18

                                    :-O

                                    Learn from the mistakes of others, you may not live long enough to make them all yourself.

                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • World
                                    • Users
                                    • Groups