Sourcery icon indicating copy to clipboard operation
Sourcery copied to clipboard

Large numbers in arguments are printed in scientific notation

Open SpacyRicochet opened this issue 2 years ago • 2 comments

When running Sourcery with a large number as one of its arguments, using the argument in a stencil will instead give the number's scientific notation.

As simple example, you can execute the following commands in your terminal;

mkdir scientificFooBar
cd scientificFooBar
echo "\"{{ argument.foobar }}\"" > FooBar.stencil
echo "enum FooBar {}" > FooBar.swift
FOOBAR=123456789
sourcery \
--quiet \
--templates FooBar.stencil \
--output FooBar.generated \
--args foobar=$FOOBAR \
--sources .
cat FooBar.generated

The expected result here is the output "123456789", but instead you get "1.234568e+08".

Tested on Sourcery 1.8.1.

SpacyRicochet avatar Jul 22 '22 18:07 SpacyRicochet

I believe if you wrap the value in double quotes and single quotes, it should work fine

FOOBAR="'123456789'"

ghost avatar Nov 29 '22 15:11 ghost

I believe if you wrap the value in double quotes and single quotes, it should work fine FOOBAR="'123456789'"

Fair enough, hopefully that will end up helping someone else that encounters this before it is fixed. Thanks for commenting 😄

SpacyRicochet avatar Dec 09 '22 10:12 SpacyRicochet