简体   繁体   中英

What data type should i use when i know the answer could be negative

I'm currently working on a program to return a jumbled image to their original state. To do this I'm using the Sum of Squared differences algorithm. Due to the nature of this algorithm it's possible that the differences between two pixels could be negative, what data should i be using to correctly hold a negative value?

I'm currently using a double but I often find that the resulting "score" that was calculated was a "out of bounds number" - by this i mean one with letters - I know that the error is occurring at this location.

Many thanks

Could you post the code? Also, what Eric Finn says is correct. Double is able to hold neagtive values, so this should work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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