Ruben, Think about that: even if you would like to implement this on a PC let's say in C++, you would have to implement an *operator overloading*. This is equivalent to writing *AddTwo128BitNumbers *function. Either way, if you need more functionality - you gotta get dirty :)
Arik On Wed, Jan 20, 2010 at 18:47, Paul Johnson <[email protected]> wrote: > Ruben, > > 1) Is easily solved by replacing void with your own custom enum > (127biterror_t) or something equivalent, and returning that whenever you > perform an operation. It should be fairly trivial to check for error > cases like overflow, divide by 0, etc. in software and return the > appropriate code that you define (e.g. EOVERFLOW). Normally on the > microprocessor, there is a flag that is set when an arithmetic operation > causes an overflow, but taking advantage of that forces you to > specialize your implementation for specific hardware, making it less > portable > > 2) Most likely, you should implement the most common operations that you > think will need in the near future. You will probably want > addition/subtraction, multiplication/division, negation(if you plan on > supporting signed numbers) and possibly some bit-wise operations if you > think they are valuable(bitwise AND,OR,XOR). These should probably get > you 95% of your use cases unless you are needing to do something unusual > with the 128 bit number. > > To my knowledge, there is no "built-in" way of handling new data types > as there is no way the compiler could determine how the basic operations > should be performed. The compiler couldn't determine if you wanted a > 128 bit long integer VS a 4x4 matrix of 8-bit number multiplication for > example. > > Hope this helps, > -Paul > > On 1/20/2010 10:16 AM, Ruben Rios del Pozo wrote: > > Thank you Arik for your quick answer :-), > > > > > >> But basically you will still have to write a function. Although I don't > see > >> a problem in that: > >> void AddTwo128BitNumbers(VeryBig first, VeryBig second, VeryBig > *result); > >> > >> > > Either I see a problem in writing such a function at first but if I > > look at it a little bit more in detail, there are a few things that > > make me feel unconfortable: > > > > 1.- Dealing with overflows and that kind of stuff > > 2.- Now is addition but maybe tomorrow I need a division or any other > > arithmetic operation > > > > That's why I was wondering if there was a built-in way of handling this. > > Once more, thank you! > > _______________________________________________ > > Tinyos-help mailing list > > [email protected] > > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > > > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > -- Best Regards, Arik Sapojnik [email protected]
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
