Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » What happened to long ints?
What happened to long ints? [message #1718] Wed, 15 March 2006 18:19 Go to next message
tercero12 is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
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 Go to previous messageGo to next message
tercero12 is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
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
Re: What happened to long ints? [message #1722 is a reply to message #1721] Wed, 15 March 2006 20:08 Go to previous messageGo to next message
tercero12 is currently offline  tercero12
Messages: 4
Registered: March 2006
Junior Member
That sounds like it will work. Converts are a cool idea.

However, I don't understand how I could use it to customize an edit field. Can you help me out a little more here?

Thanks
Re: What happened to long ints? [message #1723 is a reply to message #1722] Wed, 15 March 2006 20:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
tercero12 wrote on Wed, 15 March 2006 14:08

That sounds like it will work. Converts are a cool idea.

However, I don't understand how I could use it to customize an edit field. Can you help me out a little more here?

Thanks



See reference/Convert.

Mirek
Re: What happened to long ints? [message #1724 is a reply to message #1722] Wed, 15 March 2006 20:37 Go to previous message
tercero12 is currently offline  tercero12
Messages: 4
Registered: March 2006
Junior Member
Nevermind, I see the example convert code and it looks like it will work nicely.
Previous Topic: Core defs.h double definintion [BUG][FIXED]
Next Topic: why there is no String.MakeLower() and what are the alternatives?
Goto Forum:
  


Current Time: Thu May 02 04:31:38 CEST 2024

Total time taken to generate the page: 0.04059 seconds