Grasshopper

algorithmic modeling for Rhino

Hi,

I know this is more stackoverflow question but I would like to ask how to translate this Java Class declaration to c#?

public strictfp final class myClassName implements Serializable, Comparable<Object>, Cloneable {

...

}

so far I get this part in C#:

public class myClassName: ISerializable, IComparable<object>, ICloneable{

...

}

But what does strictfp and final mean and is there similar thingy in C# ?

Views: 1303

Replies to This Discussion

Thank you for a reply.

Features of Java Absent in C#

• Java's strictfp keyword guarantees that the result of floating point operations remain the same across platforms.

• Java supports checked exceptions for better enforcement of error trapping and handling.

Is it the same in C# checked / unchecked?

I don't play with Java but as far as C# checked is concerned ... it's way faster to check an overflow at run-time with some sort of simple check.

Say:

public void DoSomething(int i, int j, ref int result){

   if((long)int * (long)j > int.MaxValue) Print("Overflow: adios amigos");

   else result = i*j;

}

That said checked could yield ridiculously stupid stuff:

public void OnlyForIdiots(){
    short a = 0; short b = 100;
    try {
      while (true){
        checked {a++;}
        unchecked{b++;}
      }
    }
    catch {Print("a: {0}, b: {1}", a, b);}
  }

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service