You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please test for out-of-range integers on the RHS and convert them to double-precision instead of silently wrapping them into negative numbers. Current and desired behavior:
zender@firn:~$ ncap2 -O -v -s 'foo=289788500' ~/nco/data/in.nc ~/foo.nc # works
zender@firn:~$ ncks -v foo ~/foo.nc
netcdf foo {
variables:
int foo ;
data:
foo = 289788500 ;
} // group /
zender@firn:~$ ncap2 -O -v -s 'foo=28978850000' ~/nco/data/in.nc ~/foo.nc # borken, should produce type double instead
zender@firn:~$ ncks -v foo ~/foo.nc
netcdf foo {
variables:
int foo ;
data:
foo = -1085921072 ;
} // group /
zender@firn:~$
The text was updated successfully, but these errors were encountered:
I agree that wrapping is rarely a desired effect. Silent type conversion is also a nasty feature. I would prefer it to crash on such occasion and request user to explicitly specify it with "double(..)" or just by adding a period after the number. If a person wants to fit such a number into integer, they better know what they are doing.
Also, consider a case when wrapping occurs as a result of some arithmetic. Then again, capturing wrapping could save hours of debugging...
I have had a good look at the grammar.
The issue I have with converting an out of range integer to a NC_DOUBLE is that I will have to have to perform the type conversion twice. on the first parse and again on the second parse. Otherwise there will be a conflict between say an NC_INT on the first parse and say a NC_DOUBLE on the second parse. I don't see the need of adding this overhead for such a rarely ocuring event.
I have added range checking for all non-float number conversions.
If the number is out of range then an error message is emitted and ncap2 terminates.
This may break some scripts !! Especially some with ram variables !!
Will add to repo tomorrow
Please test for out-of-range integers on the RHS and convert them to double-precision instead of silently wrapping them into negative numbers. Current and desired behavior:
The text was updated successfully, but these errors were encountered: