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 » StrIntValue -> uses int64
StrIntValue -> uses int64 [message #17805] Fri, 29 August 2008 17:27 Go to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
I ran into a snag when using StrIntValue(). I assumed it stored an int, but it in fact uses int64. I had a few moments of confusion because of this. I suggest we have 2 functions, one StrIntValue() that uses int type and StrInt64Value() that uses int64 type so that others aren't confused. In the end, I just ended up using Value(StrInt(num)) instead of StrIntValue(num).
Re: StrIntValue -> uses int64 [message #17810 is a reply to message #17805] Fri, 29 August 2008 20:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Hm somehow I do not see which problems you have hit.

Value is conversible. The only possible issue I can see is that text represents something that does not fit into 'int' but does into 'int64'...

(Hm, would it be a good idea if conversions checked this and returned Null in such case?).

Mirek
Re: StrIntValue -> uses int64 [message #17822 is a reply to message #17810] Sat, 30 August 2008 01:40 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Example:
 Value my_value = StrIntValue("5");
//...
int val = ValueTo<int>(my_value);

I expected this to work, but it didn't. Gave me errors about int64...

Quote:

(Hm, would it be a good idea if conversions checked this and returned Null in such case?).

Not sure, on one hand, I knew where to look because it had the error, but on the other hand, returning Null would stop error from happening in program.

[Updated on: Sat, 30 August 2008 01:42]

Report message to a moderator

Re: StrIntValue -> uses int64 [message #17823 is a reply to message #17822] Sat, 30 August 2008 01:51 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
What about automatic up-conversion to int64 if string is deemed to be too large for int?

Then, ValueTo<int> would be Null and ValueTo<int64> would be fine. The user can check the Value's type with the usual my_value.Is<int>().

[Updated on: Sat, 30 August 2008 01:55]

Report message to a moderator

Re: StrIntValue -> uses int64 [message #17825 is a reply to message #17822] Sat, 30 August 2008 01:53 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ops.

int val = my_value;

would work Smile

Mirek
Previous Topic: String filter whitespace
Next Topic: [FEATURE REQUEST] could Alloc fail a little more gracefully?
Goto Forum:
  


Current Time: Thu Mar 28 20:57:31 CET 2024

Total time taken to generate the page: 0.01602 seconds