Convert a Long to base 36 to scala
source link: https://www.codesd.com/item/convert-a-long-to-base-36-to-scala.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Convert a Long to base 36 to scala
How can I convert a Long to base36 ? Along with your answer can explain how you came to the answer?
I've checked the scaladocs for Long for converting to a different base, and on converting a Long to a BigInt. I saw that BigInt does have toString( base )
so a solution could involve changing the type, but I couldn't figure out how.
Note: I'm new to scala / java / type-safe languages so I could be overlooking something trivial.
The class java.lang.Long has a static method toString(long i, int radix) which will convert a Long into a string representation of another base. "Radix" means the same thing as "base" in this context.
val myLong = 25000L
val longInBase36:String = java.lang.Long.toString(myLong, 36)
Scala will treat your scala Long value as a java.lang.Long when necessary, so you can always look for methods in the Java API documentation when necessary. See: http://docs.oracle.com/javase/6/docs/api/java/lang/Long.html
Related Articles
How to convert a long binary string to an integer in python? (base & gt; 36)
how to convert an Iterator [Long] to Iterator [String] in scala
Converting a Spark Data Frame to a Scala Map Collection
How to convert format Long Value 20010203 to string 2001-02-03?
How to convert unsigned long string
How can I easily convert a line angle to a navigation scale (ie with a range of [0.360] and & ldquo; North & rdquo; = 0 deg)?
How to convert a long string into a binary string?
C ++: Convert a long unsigned interval to a vector & lt; uint8_t & gt; raw data
A double javascript function to convert a long date and return today's date in mm-dd-aaa format
convert java.util.Map [String, Object] to scala.collection.immutable.Map [String, Any]
C ++: Converts unsigned long long int into vector & lt; char & gt; and vice versa
Timestamping of the PHP Integer Database to the Long Java Base Timestamp
Convert a long .NET to an unsigned 8-byte integer
How to convert a long Java to a * unsigned * base-X String (and back)?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK