简体   繁体   English

长时间保持前导零SQLITE插入

[英]Does long keep Leading zeros SQLITE Insert

Simple Question just to confirm. 简单的问题只是为了确认。 A method returns a Long, that long may be made up of leading zeros. 方法返回Long,该long可能由前导零组成。 What are the rules on this. 有什么规则。 Are the zeros wiped off when it's passed back or do they stay. 传递回去时零消失了还是保留了?

Ahh I realised where this gets more complexed I am currently using this method to add values to a database, it returns a LONG. 啊,我意识到这变得更复杂了,我目前正在使用此方法向数据库添加值,它返回一个LONG。 Android SQLiteDatabase.Insert Android SQLiteDatabase.Insert

So I'm wondering if it returns something with a leading zero what's stopping it being chopped off? 因此,我想知道它是否返回前导零的内容,这是什么原因导致它被斩断?

No integral type (or floating point type) preserves leading zeros. 没有整数类型(或浮点类型)保留前导零。 In binary, there is no concept of 00 vs 0 (nor in a mathematical sense). 在二进制中,没有00 vs 0概念(从数学意义上来说也不是)。

System.out.println(Long.toBinaryString(Long.parseLong("001")));
System.out.println(Long.toBinaryString(Long.parseLong("1")));

Is just going to display 1 for both. 两者都将显示1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM