I have a set of values returned from the web service as strings in formats such as XXXXX or XXXXXX or XXXXXX..., the number of digits may differ.
I want to convert them from the above mentioned formats to something with $x,xxxK.
How to do that?
Please let me know your thoughts.
Thanks
use [str doubleValue];
then divide by 1000 to or more to set your desired format
Related
I have a field which is a Number(decimal) here's one such example value:
1005.44
now if I try to convert that to a string to simply get me what is seen; I'd expect STR = 1005.44
but instead I get:
1005.4400000000001
thats from STR(ROUND(([FIELD]),2))
I see some other posts with similar issues but no found resolution?
This artifact isn't unique to Tableau and stems from how underlying databases store floating point numbers and deal with functions like rounding.
You should try the following:
str(int([FIELD]*100)/100)
This will multiply the number by 100, convert to an int, divide by 100, and then convert to a string.
I am facing issue with coordinate calculation (Longitude and Latitude). I have a pcap file when I open it with Wireshark I am getting the packet as shown below -
Latitude: 52.5125915 (52°30'45.33"N) (525125915)
Longitude: 13.3335368 (13°20'00.73"E) (133335368)
But when I am copying the value manually or exporting the pcap into a JSON file I am getting the value as (525125915).
So I need to know how to convert the value into "Decimal Degrees" format.
Note:
I have searched for conversion options but all the articles I found refer to "DD to DMS" or "DMS to DD" conversion but I could not find any formula / documents to convert a number to coordinate degree.
I have also tried converting the number to degree but it will not work for above case!
Thanks in advance.
Shahneel
I have found a workaround for most of the sites they are doing it like following example -
int(val)/10000000.0
For 525125915/10000000 it is now showing as 52.5125915
Thanks
i have strings who look like this 20110525 .
how can i make to put '-' caracters in NSString variable ? to let dates look like this 2011-05-25 ?
My second question is how can i sort the dates to make the table look like this 20110525 then 20110526 ?Help please . Thank you
Why not just use the NSDate class to get the date, and use an NSDateFormatter to format the date the way you want.
you can try using sscanf(input,"%4d%2d%2s",&year,&month,&day) to parse input string and sprintf(output,"%d-%d-%d",year,month,day) to format your date.
Am getting date (10/02/2011) in xmlresponse how to get this value in to string using NSXmlParserDelegate. "/" blocks me and am not getting how to handle this..
Thanks in advance..
Use NSDateFormatter to get date from NSString from any formats.
You have not been clear where this xml data is coming from, I couldnt turn anything up on how dates should be formatted in xml. The first thought is "you are doing it wrong" if you can try using a different separator for dates, parse them out of the stream before you give the data to NSXMLParser. I know which I would prefer.
For example, I have an NSDecimal myDecimal. Lets say it represents something like "-1234567.89"
How can I get a clean string representation of that decimal without any beautification / formatting? No localization? Floating point symbol = . and rest only numbers from 0 to 9, and eventually an - if it is negative? I need that string in strict technical manner. A number like 123456789876554432123456789.2231 should therefore not look like nice formatted "123,456,789,876,554,432,123,456,789.2231". You get the point right?
I don't want any formatting. I'm trying all day now to get that right but everything I find always has to do with formatting. So how'd you guys do that?
I don't believe there is such a thing as a "clean" string representation independent of specifying the locale. As many Europeans would point out, 123.45 should be written as 123,45 (using , instead of . for the decimal location). NSDecimalString() (which can be found in the Foundation Functions Reference) takes, as a second parameter a locale specification. If some locale uses the format you desire, pass that locale as the second parameter (see the Internationalization Guide for more info on locales).
Alternatively, you can use an NSNumberFormatter, which will give you more controll over the string representation.
For easy (localized) control use an NSNumberFormatter.
float number = 12.345;
NSString* numberString = [NSString stringWithFormat:#"%f", number];
That will give you consistent formatting regardless of the user's current locale.