How to input a float without decimal places in [text] (example: "1.")

Jdudeo's icon

so I want to put a float into [text] as 1.
it seems to automatically get converted to 1.000
any way around this? using [tosymbol] makes it 1.0000

rubén's icon

i have the same problem, can´t find a solution with my short skills :(

Jdudeo's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I managed to get around this with regexp, but only because my floats were between html tags so including the tags made the whole thing a symbol. You could hack this though by using some kind of placeholder after floats though and deleting them on the way out, try this..

Pedro Santos's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Yeah, the problem is that whenever Max is interpreting the "1." as a float (almost always, except for lists, symbols within commas, etc), it adds zeros.
Another possible solution:

Jdudeo's icon

that's cool, you lose the ability to differentiate between what was a float on the way in and what wasn't but I guess it depends on usage

Rick's icon
Max Patch
Copy patch and select New From Clipboard in Max.

FWIW the default float precision for [text] is three. You can change it to zero but your floats will be truncated to int.

dimbels's icon

Still haven't found a way to convert a string such as:
"Lorem Ipsum 2. Dolor sit amet."
into a symbol without sprintf symout or tosymbol automatically converting it to :
"Lorem Ipsum 2.000 Dolor sit amet."
I can set the precision for the text lower, but symout/tosymbol still add the decimal places. Any alternatives? Maybe an invisible Escape-Character I can add after a number?

metamax's icon
Max Patch
Copy patch and select New From Clipboard in Max.

metamax's icon

Still haven’t found a way to convert a string such as:
"Lorem Ipsum 2. Dolor sit amet."

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

"You can change it to zero but your floats will be truncated to int."

that is exactly why it ant work to write 1. in a messagebox or text objekt, without any digits behind the comma it just does not make sense.

if these objects would support writing 1. as symbol, people would complain why it is not outputted as float; you will need numbers to be numbers in most cases.

-110

Jdudeo's icon

I think if it treated 1. as a symbol and you wanted it as a float it would be easy to substitute it with something like (\\d+)\. @substitute %1.0 (been a while since I've used Max's regex)

I understand why it's a difficult situation but the reason this was messing with me is because I was trying to process text from a webpage and when you have sentences that end in ints (followed by full stop) and you also have floats that have decimal places, it becomes quite difficult to preserve them respectively in the output.

metamax's icon

the reason this was messing with me is because I was trying to process text from a webpage and when you have sentences that end in ints (followed by full stop) and you also have floats that have decimal places, it becomes quite difficult to preserve them respectively in the output.

The message object is designed to process messages, not text. It's easy to forget that because they can be used to process text a lot of time. Just not all of the time.

Jdudeo's icon

I'm not sure what you're getting at? I had to use a text object to load the html file downloaded with jit.uldl and iterate through the lines, the lines were processed by a variety of regexes etc. and sequentially appended to another blank text object.

dimbels's icon

thank you metamax, I'll be sure to check out your patch and see if the iter adds any considerate amount to the processing. I am using it to read out textfiles and forward them via udp, so in this case it's helpful to just ignore special handling of floats alltogether in some manner.

metamax's icon

@jdudeo I didn't ready the thread carefully. I only saw your example with a message box at the top. Sorry about that. Slippery problem for sure.