Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6689929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:34:36+00:00 2026-05-26T05:34:36+00:00

If you declare a numeric vector with a mix of decimal and integer values

  • 0

If you declare a numeric vector with a mix of decimal and integer values and print it, all of them are converted to a decimal number.

s <- c(0, 1.1, 2, 3)
print(s)
[1] 0.0 1.1 2.0 3.0

but if you use cat instead of print, each number is formatted according to its type.

cat(s, sep=" ")
0 1.1 2 3 

How can you print a numeric vector using cat but converting the values to decimal numbers as print does?

Best

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:34:37+00:00Added an answer on May 26, 2026 at 5:34 am

    You can use format:

    cat(format(s,digits=2))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to declare my own numeric types, exactly like unsigned int, but I
i am multipying the values in the query DECLARE @Rate DECLARE @numeric DECLARE @Result
Declare @BadDecimal varchar(5) Set @BadDecimal = '4.5' Declare @GoodDecimal Decimal Set @GoodDecimal = @BadDecimal
i declare a global variable and use and modify its value in the function.
The documentation for SQL Server Float says Approximate-number data types for use with floating
We can not declare an integer which start with 0. >>> n = 08
If I have statement DECLARE @i INT; DECLARE @d NUMERIC(9,3); SET @i = 123;
CREATE PROCEDURE [dbo].[PL_GEN_PROVN_NO1] @GAD_COMP_CODE VARCHAR(2) =NULL, @@voucher_no numeric =null output AS BEGIN DECLARE @NUM
declare @a varchar(40) set @a='1.23e-4' declare @b decimal(27,12) if isnumeric(@a) =1 begin select @b=cast(@a
I'm getting this error: ORA-06502: PL/SQL: numeric or value error: character to number conversion

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.