Java String科学计数法转long
时间: 2023-10-17 08:36:13 浏览: 311
在Java中,将科学计数法的字符串转换为long类型的方法有多种。下面是其中一种方法的示例代码:
```java
public class Test {
public static void main(String[] args) {
String num = "1.23456E10";
Long result = Double.valueOf(num).longValue();
System.out.println(result);
}
}
```
在这个示例中,我们使用Double的valueOf方法将科学计数法的字符串转换为double类型,然后再使用longValue方法将其转换为long类型。这样就可以将科学计数法的字符串转换为long类型的数值。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Long类型转科学计数法](https://blog.csdn.net/luck_jinwei/article/details/108843582)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [java中处理科学计数法问题](https://blog.csdn.net/weixin_41657954/article/details/124185179)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文