Home » U++ Library support » U++ Core » What happened to long ints?
What happened to long ints? [message #1718] |
Wed, 15 March 2006 18:19 |
tercero12
Messages: 4 Registered: March 2006
|
Junior Member |
|
|
I have been using upp for a few weeks now for a school project. (Namely, to emulate a simple RISC processor in software at the register level.)
I quickly found out that upp sort of ignored implementing long ints when it implemented conversion functions and Values. In the mean time I wrote my own conversion functions but it would be supernice to have have to wrap every long I use in order to pass it to a function that takes a Value.
Am I missing something? Can a Value support a long? If I were to implement this functionality into UPP, would my code be accepted?
|
|
|
Re: What happened to long ints? [message #1719 is a reply to message #1718] |
Wed, 15 March 2006 18:52 |
|
mirek
Messages: 14105 Registered: November 2005
|
Ultimate Member |
|
|
tercero12 wrote on Wed, 15 March 2006 12:19 | I have been using upp for a few weeks now for a school project. (Namely, to emulate a simple RISC processor in software at the register level.)
I quickly found out that upp sort of ignored implementing long ints when it implemented conversion functions and Values. In the mean time I wrote my own conversion functions but it would be supernice to have have to wrap every long I use in order to pass it to a function that takes a Value.
Am I missing something? Can a Value support a long? If I were to implement this functionality into UPP, would my code be accepted?
|
Well, it is true that number of fundamental types that can be directly stored into Value is deliberately limited to bool, int, double and int64.
In practice, however, the question is why do you need to store long int? If you just want to store 32-bit value, use "int" (typecast if you source contains long). In U++ int is required to have at least 32 bits. If you need 64, use int64.
Mirek
|
|
|
Re: What happened to long ints? [message #1720 is a reply to message #1719] |
Wed, 15 March 2006 19:35 |
tercero12
Messages: 4 Registered: March 2006
|
Junior Member |
|
|
luzr wrote on Wed, 15 March 2006 11:52 |
Well, it is true that number of fundamental types that can be directly stored into Value is deliberately limited to bool, int, double and int64.
In practice, however, the question is why do you need to store long int? If you just want to store 32-bit value, use "int" (typecast if you source contains long). In U++ int is required to have at least 32 bits. If you need 64, use int64.
Mirek
|
I mentioned that I'm doing this for a school assignment. Part of the assignment is that the "computer" that we are emulating has 32-bit registers. This is fine and I could use ints or int64s but when I use EditInt, it just can't seem to handle 2^32 unique values. I guess this may be the real rub. Thoughts?
|
|
|
Re: What happened to long ints? [message #1721 is a reply to message #1720] |
Wed, 15 March 2006 19:58 |
|
mirek
Messages: 14105 Registered: November 2005
|
Ultimate Member |
|
|
tercero12 wrote on Wed, 15 March 2006 13:35 |
luzr wrote on Wed, 15 March 2006 11:52 |
Well, it is true that number of fundamental types that can be directly stored into Value is deliberately limited to bool, int, double and int64.
In practice, however, the question is why do you need to store long int? If you just want to store 32-bit value, use "int" (typecast if you source contains long). In U++ int is required to have at least 32 bits. If you need 64, use int64.
Mirek
|
I mentioned that I'm doing this for a school assignment. Part of the assignment is that the "computer" that we are emulating has 32-bit registers. This is fine and I could use ints or int64s but when I use EditInt, it just can't seem to handle 2^32 unique values. I guess this may be the real rub. Thoughts?
|
I see. You need unsigned, what you get is signed with Null, right?
I guess, the right solution is to define Convert using int64, limit it to unsigned 0-2^32 range, use its regular Null if needed. Use this Convert to customize your editfield (you can also learn it other useful things like hexadecimal syntax etc...)
Mirek
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:29:39 CET 2024
Total time taken to generate the page: 0.00998 seconds
|