Thank you all very much for all the contributions, now its clear to me
that "I gotta get dirty", in Arik words :-) I really appreciate your
comments but there's still something I need to ask:

a) which option do you recommend me for the implementation of the 128
bit data type,  a struct containing several uintX_t or an array of
uintX_t ???

b) should I use uint8_t, uint16_t, uint32_t or uint64_t ???

I know there is no a yes/no answer to these questions, but what are
the implications of using one option or the other in either cases

Thank you all,
Ruben


2010/1/20 Arik Sapojnik <[email protected]>:
> 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
>

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to