Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Storing NSNumber as a double type may cause data loss when storing long long type. #1493

@cntrump

Description

@cntrump

If I store data of type long long (such as 95811454522411188) into a WCDB database and then read and process it, I find that the data is different from before. By examining the source code, I discovered that long long is being stored as a double.

return WCTColumnTypeFloat;

#import "NSNumber+WCTColumnCoding.h"

@implementation NSNumber (WCTColumnCoding)

+ (instancetype)unarchiveWithWCTValue:(NSNumber *)value
{
    return value;
}

- (NSNumber *)archivedWCTValue
{
    return self;
}

+ (WCTColumnType)columnType
{
    return WCTColumnTypeFloat;
}

@end

It's best to explicitly specify whether the database field type is long long or double.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions