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. math functions in C# ???

math functions in C# ???

Scheduled Pinned Locked Moved C#
csharpquestion
20 Posts 8 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.
  • C Christian Graus

    Got it. I typed System.Math and intellisense did not find it, so I assumed it did not exist. I need to get Visual Assist on here, pronto. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

    K Offline
    K Offline
    Kannan Kalyanaraman
    wrote on last edited by
    #8

    Christian Graus wrote: I need to get Visual Assist on here, pronto. I think vs.net behaves bit more nicely than the vstudio for intellisense. Its able to pickup most of the classes and variables. But I've read somewhere(dont remember where i read) that VA is not so stable for vstudio.net, I guess the beta status explains that a bit. Cheers Kannan

    1 Reply Last reply
    0
    • D David Wengier

      Thanks for the info :) Christian Graus wrote: VA does the case correction, C# does not by itself. Thats the impression I got. I must say, it strikes me as silly that that is the case however. It means that whatever is doing the case correction is not built into the editor, but actually into the bit that each language provides to plug-in to the editor. Or at least, so it would seem. After being used to it in VB since 16-bit VB3, it certainly takes a bit of getting used to :) -- David Wengier Sonork ID: 100.14177 - Ch00k

      A Offline
      A Offline
      Anders Molin
      wrote on last edited by
      #9

      David Wengier wrote: I must say, it strikes me as silly that that is the case however. Well, VB is not case sensitive, SomeClass and someclass is the same thing. In both C++ and C# SomeClass and someclass is two different classes because the languages are case sensitive. Because of that I think it would be *very* dificult to make C++ and C# correct the case for you. I mean, if you have 2 int's called IntOne and intOne, and you just typed intone, which one should the IDE select? ;) - Anders Money talks, but all mine ever says is "Goodbye!"

      D C 2 Replies Last reply
      0
      • A Anders Molin

        David Wengier wrote: I must say, it strikes me as silly that that is the case however. Well, VB is not case sensitive, SomeClass and someclass is the same thing. In both C++ and C# SomeClass and someclass is two different classes because the languages are case sensitive. Because of that I think it would be *very* dificult to make C++ and C# correct the case for you. I mean, if you have 2 int's called IntOne and intOne, and you just typed intone, which one should the IDE select? ;) - Anders Money talks, but all mine ever says is "Goodbye!"

        D Offline
        D Offline
        David Wengier
        wrote on last edited by
        #10

        This is a very good point, which in fact I didnt know about C#. -- David Wengier Sonork ID: 100.14177 - Ch00k

        1 Reply Last reply
        0
        • A Anders Molin

          David Wengier wrote: I must say, it strikes me as silly that that is the case however. Well, VB is not case sensitive, SomeClass and someclass is the same thing. In both C++ and C# SomeClass and someclass is two different classes because the languages are case sensitive. Because of that I think it would be *very* dificult to make C++ and C# correct the case for you. I mean, if you have 2 int's called IntOne and intOne, and you just typed intone, which one should the IDE select? ;) - Anders Money talks, but all mine ever says is "Goodbye!"

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

          Anders Molin wrote: I mean, if you have 2 int's called IntOne and intOne, and you just typed intone, which one should the IDE select? This is a problem I have with VA at work - our class library includes try/catch wrappers which specify a HRESULT called hResult. Every time I type hResult, it turns it all to capitals, as it does not expand the macro and see the variable name. If VB is not case sensitive ( and how gay is THAT ? ), then the IDE isn't doing any case correction at all, it's simply ignoring it - right ? Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

          J 1 Reply Last reply
          0
          • C Christian Graus

            I know, thanks, I just had not reinstalled it just yet after all the hassles I had getting .NET installed at all. Intellisense is working, Matk is a class. How gay - I have to type Math.Min when I want to min something ? I suppose I could type Math m; m.Min, but it still sucks. C# is pretty cool though, but I need to do some testing. I am convering an image library I wrote using GDI+ in C++ and I think initially it is orders of magnitude slower doing exactly the same thing as the C++ code I wrote prior. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

            J Offline
            J Offline
            James T Johnson
            wrote on last edited by
            #12

            Christian Graus wrote: Matk is a class. How gay - I have to type Math.Min when I want to min something ? Welcome to the world of "everything is an object" :) James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

            1 Reply Last reply
            0
            • C Christian Graus

              Anders Molin wrote: I mean, if you have 2 int's called IntOne and intOne, and you just typed intone, which one should the IDE select? This is a problem I have with VA at work - our class library includes try/catch wrappers which specify a HRESULT called hResult. Every time I type hResult, it turns it all to capitals, as it does not expand the macro and see the variable name. If VB is not case sensitive ( and how gay is THAT ? ), then the IDE isn't doing any case correction at all, it's simply ignoring it - right ? Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

              J Offline
              J Offline
              James T Johnson
              wrote on last edited by
              #13

              Christian Graus wrote: If VB is not case sensitive It isn't case sensitive Christian Graus wrote: how gay is THAT ? And the VB programmers proclaim that it is gay that C/C++ IS case-sensitive. Until you get used to it, there doesn't seem to be any reason for case to matter; why would you want a variable named foo and Foo? Once you're used to it you quickly realize that (according to my style) foo is protected and Foo is public. When I coded in VB since case matter I prefixed private members with _. A practice many C/C++ people have followed as well. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

              D 1 Reply Last reply
              0
              • J James T Johnson

                Christian Graus wrote: If VB is not case sensitive It isn't case sensitive Christian Graus wrote: how gay is THAT ? And the VB programmers proclaim that it is gay that C/C++ IS case-sensitive. Until you get used to it, there doesn't seem to be any reason for case to matter; why would you want a variable named foo and Foo? Once you're used to it you quickly realize that (according to my style) foo is protected and Foo is public. When I coded in VB since case matter I prefixed private members with _. A practice many C/C++ people have followed as well. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                D Offline
                D Offline
                David Wengier
                wrote on last edited by
                #14

                James T. Johnson wrote: When I coded in VB since case matter I prefixed private members with _. A practice many C/C++ people have followed as well. Okay, I know I will get flamed for this, but why prefix private members with anything? I dont expose variables publically, but use property methods that are public, so I never have public variables. As for private methods, why would you prefix them at all? :confused: -- David Wengier Sonork ID: 100.14177 - Ch00k

                J 1 Reply Last reply
                0
                • D David Wengier

                  James T. Johnson wrote: When I coded in VB since case matter I prefixed private members with _. A practice many C/C++ people have followed as well. Okay, I know I will get flamed for this, but why prefix private members with anything? I dont expose variables publically, but use property methods that are public, so I never have public variables. As for private methods, why would you prefix them at all? :confused: -- David Wengier Sonork ID: 100.14177 - Ch00k

                  J Offline
                  J Offline
                  James T Johnson
                  wrote on last edited by
                  #15

                  oops, guess I shouldn't be replying to messages after I wake up from sleeping on a long ride home. I should have said private variables; because in many cases in my code a private variable would have a public get or get/set property defined for it. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                  D 1 Reply Last reply
                  0
                  • J James T Johnson

                    oops, guess I shouldn't be replying to messages after I wake up from sleeping on a long ride home. I should have said private variables; because in many cases in my code a private variable would have a public get or get/set property defined for it. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

                    D Offline
                    D Offline
                    David Wengier
                    wrote on last edited by
                    #16

                    James T. Johnson wrote: I should have said private variables; because in many cases in my code a private variable would have a public get or get/set property defined for it. ahhh yes... I use "m" as a prefix, so I know the variable is "mine". -- David Wengier Sonork ID: 100.14177 - Ch00k

                    1 Reply Last reply
                    0
                    • C Christian Graus

                      I know, thanks, I just had not reinstalled it just yet after all the hassles I had getting .NET installed at all. Intellisense is working, Matk is a class. How gay - I have to type Math.Min when I want to min something ? I suppose I could type Math m; m.Min, but it still sucks. C# is pretty cool though, but I need to do some testing. I am convering an image library I wrote using GDI+ in C++ and I think initially it is orders of magnitude slower doing exactly the same thing as the C++ code I wrote prior. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

                      P Offline
                      P Offline
                      Paul Watson
                      wrote on last edited by
                      #17

                      Christian Graus wrote: Intellisense is working, Matk is a class. How gay - I have to type Math.Min when I want to min something ? I suppose I could type Math m; m.Min, but it still sucks. Funny how I lile the fact that I have to type in the class name first and then it's method to use it, while you think it is naff. I guess I like the structure of it, it helps to structure the app in my head better than if all I had to type was Min. Just FYI, and you probably do know this, you can instead of doing Math m do using m = System.Math;. Has much the same affect, but it is across your whole class, not just a procedure. And the old way would be to just wrap it in a normal function called Min of course :-D I must say .NET is the first system that I have really started to understand the underlying structure of. VB I just cruised along and did not really care much whether something was an object, class, blahdingaling or whatsamacallit. But with .NET the whole framework of classes and namespaces really just works for me. I certainly now see the advantage of understanding the underlying strutcute when it comes to developing :-D *sigh* there go my days of sticky-tape-and-glue APPs :rolleyes: regards, Paul Watson Bluegrass Cape Town, South Africa "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge Sonork ID: 100.9903 Stormfront

                      C 1 Reply Last reply
                      0
                      • P Paul Watson

                        Christian Graus wrote: Intellisense is working, Matk is a class. How gay - I have to type Math.Min when I want to min something ? I suppose I could type Math m; m.Min, but it still sucks. Funny how I lile the fact that I have to type in the class name first and then it's method to use it, while you think it is naff. I guess I like the structure of it, it helps to structure the app in my head better than if all I had to type was Min. Just FYI, and you probably do know this, you can instead of doing Math m do using m = System.Math;. Has much the same affect, but it is across your whole class, not just a procedure. And the old way would be to just wrap it in a normal function called Min of course :-D I must say .NET is the first system that I have really started to understand the underlying structure of. VB I just cruised along and did not really care much whether something was an object, class, blahdingaling or whatsamacallit. But with .NET the whole framework of classes and namespaces really just works for me. I certainly now see the advantage of understanding the underlying strutcute when it comes to developing :-D *sigh* there go my days of sticky-tape-and-glue APPs :rolleyes: regards, Paul Watson Bluegrass Cape Town, South Africa "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge Sonork ID: 100.9903 Stormfront

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

                        Paul Watson wrote: Funny how I lile the fact that I have to type in the class name first and then it's method to use it, while you think it is naff. I guess I like the structure of it, it helps to structure the app in my head better than if all I had to type was Min. I dunno what VB offers, but in C++, math is a library which provides these functions, so I am just used to the language offering maths facilities without the need for my code to be full of Math. Paul Watson wrote: Just FYI, and you probably do know this, you can instead of doing Math m do using m = System.Math;. Has much the same affect, but it is across your whole class, not just a procedure. Yes, I realise that, thanks. It gives me the overhead of creating a class and still looks ugly. Paul Watson wrote: And the old way would be to just wrap it in a normal function called Min of course As a C++ programmer, the old way is to wrap it in a macro, so it occurs in place. I am writing image processing code, as you will see when Chris posts the first article. Is there a way to inline code in C#, do you know ? Image processing is an area where every clock cycle counts. Paul Watson wrote: I certainly now see the advantage of understanding the underlying strutcute when it comes to developing I suspect based on what I hear that VB.NET is structed a lot better than prior versions, so it's no wonder that it's now making such things clear to you. ON the other hand, I feel C# is hiding too much from me, but I can certainly see how that is helping me develop this thing faster than I would in C++, which is a *good* thing. But it is a ton slower to process the same image as the equivelant C++ code, and I dunno how much of that is ways I cannot optimise code compared to the C++ version, and how much is the CLR. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

                        D 1 Reply Last reply
                        0
                        • C Christian Graus

                          Paul Watson wrote: Funny how I lile the fact that I have to type in the class name first and then it's method to use it, while you think it is naff. I guess I like the structure of it, it helps to structure the app in my head better than if all I had to type was Min. I dunno what VB offers, but in C++, math is a library which provides these functions, so I am just used to the language offering maths facilities without the need for my code to be full of Math. Paul Watson wrote: Just FYI, and you probably do know this, you can instead of doing Math m do using m = System.Math;. Has much the same affect, but it is across your whole class, not just a procedure. Yes, I realise that, thanks. It gives me the overhead of creating a class and still looks ugly. Paul Watson wrote: And the old way would be to just wrap it in a normal function called Min of course As a C++ programmer, the old way is to wrap it in a macro, so it occurs in place. I am writing image processing code, as you will see when Chris posts the first article. Is there a way to inline code in C#, do you know ? Image processing is an area where every clock cycle counts. Paul Watson wrote: I certainly now see the advantage of understanding the underlying strutcute when it comes to developing I suspect based on what I hear that VB.NET is structed a lot better than prior versions, so it's no wonder that it's now making such things clear to you. ON the other hand, I feel C# is hiding too much from me, but I can certainly see how that is helping me develop this thing faster than I would in C++, which is a *good* thing. But it is a ton slower to process the same image as the equivelant C++ code, and I dunno how much of that is ways I cannot optimise code compared to the C++ version, and how much is the CLR. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

                          D Offline
                          D Offline
                          Dale Thompson
                          wrote on last edited by
                          #19

                          Christian Graus wrote: As a C++ programmer, the old way is to wrap it in a macro, so it occurs in place. I am writing image processing code, as you will see when Chris posts the first article. Is there a way to inline code in C#, do you know ? Image processing is an area where every clock cycle counts. Actually - as a C++ programmer, you would wrap it in an inline function. ;) Dale Thompson

                          C 1 Reply Last reply
                          0
                          • D Dale Thompson

                            Christian Graus wrote: As a C++ programmer, the old way is to wrap it in a macro, so it occurs in place. I am writing image processing code, as you will see when Chris posts the first article. Is there a way to inline code in C#, do you know ? Image processing is an area where every clock cycle counts. Actually - as a C++ programmer, you would wrap it in an inline function. ;) Dale Thompson

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

                            Dale Thompson wrote: Actually - as a C++ programmer, you would wrap it in an inline function. Not if I was doing image processing. I hate macros, but the inline keyword is a suggestion which the compiler is free to ignore, so a macro is the best way of knowing for sure the code is running in place. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002

                            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